Skip to content
Permalink
Browse files

Merge commit '919b7bf3f194eefa739e68bf27e059abc002cc2a' into JENKINS-…

…48061
  • Loading branch information...
rsandell committed Mar 26, 2018
2 parents ac97524 + 919b7bf commit eb8f3788eac9cca440c82f2f9f9f2903f634fd39
@@ -806,7 +806,7 @@ protected SCMRevision retrieve(@NonNull final String revision, @NonNull final Ta
// WIN it's also a branch
return new GitBranchSCMRevision(new GitBranchSCMHead(StringUtils.removeStart(name, Constants.R_HEADS)),
shortHashMatch);
} else if (name.startsWith(Constants.R_HEADS)) {
} else if (name.startsWith(Constants.R_TAGS)) {
tagName = StringUtils.removeStart(name, Constants.R_TAGS);
context.wantBranches(false);
context.wantTags(true);
@@ -64,8 +64,13 @@ public SCMHead migrate(@NonNull GitSCMSource source, @NonNull SCMHead head) {
@Override
public SCMRevision migrate(@NonNull GitSCMSource source, @NonNull AbstractGitSCMSource.SCMRevisionImpl revision) {
if (revision.getHead().getClass() == SCMHead.class) {
return new GitBranchSCMRevision((GitBranchSCMHead) migrate(source, revision.getHead()),
revision.getHash());
SCMHead revisionHead = revision.getHead();
SCMHead branchHead = migrate(source, revisionHead);
if (branchHead != null) {
GitBranchSCMHead gitBranchHead = (GitBranchSCMHead) branchHead;
String revisionHash = revision.getHash();
return new GitBranchSCMRevision(gitBranchHead, revisionHash);
}
}
return null;
}
@@ -9,15 +9,16 @@
/**
* Constructor.
*
* @param name the name.
* @param name the name of the ref.
* @param ref the ref.
*/
public GitRefSCMHead(@NonNull String name, @NonNull String ref) {
super(name);
this.ref = ref;
}

/**
* Constructor where ref and name is the same.
* Constructor where ref and name are the same.
*
* @param name the name (and the ref).
*/
@@ -310,6 +310,12 @@ public void retrieveByName() throws Exception {
assertThat(rev, instanceOf(AbstractGitSCMSource.SCMRevisionImpl.class));
assertThat(((AbstractGitSCMSource.SCMRevisionImpl) rev).getHash(), is(v2Hash));

String v2Tag = "refs/tags/v2";
listener.getLogger().printf("%n=== fetch('%s') ===%n%n", v2Tag);
rev = source.fetch(v2Tag, listener);
assertThat(rev, instanceOf(AbstractGitSCMSource.SCMRevisionImpl.class));
assertThat(((AbstractGitSCMSource.SCMRevisionImpl) rev).getHash(), is(v2Hash));

}

public static abstract class ActionableSCMSourceOwner extends Actionable implements SCMSourceOwner {

0 comments on commit eb8f378

Please sign in to comment.
You can’t perform that action at this time.