Skip to content

Commit

Permalink
[JENKINS-47526] Ok that's at least enough tests for to merge with
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenc committed Oct 22, 2017
1 parent 4d95566 commit 2bee283
Show file tree
Hide file tree
Showing 3 changed files with 321 additions and 13 deletions.
20 changes: 18 additions & 2 deletions src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java
Expand Up @@ -674,7 +674,19 @@ protected SCMRevision retrieve(@NonNull final String revision, @NonNull final Ta
final String remote = getRemote();
final StandardUsernameCredentials credentials = getCredentials();
telescope.validate(remote, credentials);
return telescope.getRevision(remote, credentials, revision);
SCMRevision result = telescope.getRevision(remote, credentials, revision);
if (result != null) {
return result;
}
result = telescope.getRevision(remote, credentials, Constants.R_HEADS + revision);
if (result != null) {
return result;
}
result = telescope.getRevision(remote, credentials, Constants.R_TAGS + revision);
if (result != null) {
return result;
}
return null;
}
return doRetrieve(new Retriever<SCMRevision>() {
@Override
Expand Down Expand Up @@ -722,7 +734,11 @@ protected Set<String> retrieveRevisions(@NonNull final TaskListener listener) th
}
Set<String> result = new HashSet<>();
for (SCMRevision r : telescope.getRevisions(remote, credentials, referenceTypes)) {
result.add(r.getHead().getName());
if (r instanceof GitTagSCMRevision && context.wantTags()) {
result.add(r.getHead().getName());
} else if (!(r instanceof GitTagSCMRevision) && context.wantBranches()) {
result.add(r.getHead().getName());
}
}
return result;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/jenkins/plugins/git/GitSCMTelescope.java
Expand Up @@ -255,7 +255,7 @@ protected abstract SCMFileSystem build(@NonNull String remote, @CheckForNull Sta
*
* @param remote the repository URL.
* @param credentials the credentials or {@code null} for an anonymous connection.
* @param refOrHash the reference or hash.
* @param refOrHash the reference or hash. If this is a reference then it will start with {@link Constants#R_REFS}
* @return the timestamp.
* @throws IOException if the operation failed due to an IO error.
* @throws InterruptedException if the operation was interrupted.
Expand All @@ -268,7 +268,7 @@ public abstract long getTimestamp(@NonNull String remote, @CheckForNull Standard
*
* @param remote the repository URL.
* @param credentials the credentials or {@code null} for an anonymous connection.
* @param refOrHash the reference or hash.
* @param refOrHash the reference or hash. If this is a reference then it will start with {@link Constants#R_REFS}
* @return the revision or {@code null} if the reference or hash does not exist.
* @throws IOException if the operation failed due to an IO error.
* @throws InterruptedException if the operation was interrupted.
Expand Down Expand Up @@ -355,7 +355,7 @@ public abstract Iterable<SCMRevision> getRevisions(@NonNull String remote,
*
* @param remote the repository URL.
* @param credentials the credentials or {@code null} for an anonymous connection.
* @return the default target of the repository.
* @return the default target of the repository,
* @throws IOException if the operation failed due to an IO error.
* @throws InterruptedException if the operation was interrupted.
*/
Expand Down

0 comments on commit 2bee283

Please sign in to comment.