Skip to content
Permalink
Browse files

[JENKINS-48061] rename WantedOtherRefs to RefNameMapping

  • Loading branch information...
rsandell committed May 4, 2018
1 parent 4a7cba8 commit 36a307a5e128e5f47d2284317a6cf1e0cb4595e5
@@ -558,7 +558,7 @@ public Void run(GitClient client, String remoteName) throws IOException, Interru
}
if (context.wantOtherRefs()) {
discoverOtherRefs(repository, walk, request, remoteReferences,
(Collection<GitSCMSourceContext.WantedOtherRef>)context.getOtherWantedRefs());
(Collection<GitSCMSourceContext.RefNameMapping>)context.getRefNameMappings());
}
}
return null;
@@ -567,7 +567,7 @@ public Void run(GitClient client, String remoteName) throws IOException, Interru
private void discoverOtherRefs(final Repository repository,
final RevWalk walk, GitSCMSourceRequest request,
Map<String, ObjectId> remoteReferences,
Collection<GitSCMSourceContext.WantedOtherRef> wantedRefs)
Collection<GitSCMSourceContext.RefNameMapping> wantedRefs)
throws IOException, InterruptedException {
listener.getLogger().println("Checking other refs...");
walk.setRetainBody(false);
@@ -576,7 +576,7 @@ private void discoverOtherRefs(final Repository repository,
if (ref.getKey().startsWith(Constants.R_HEADS) || ref.getKey().startsWith(Constants.R_TAGS)) {
continue;
}
for (GitSCMSourceContext.WantedOtherRef otherRef : wantedRefs) {
for (GitSCMSourceContext.RefNameMapping otherRef : wantedRefs) {
if (!otherRef.matches(ref.getKey())) {
continue;
}
@@ -859,7 +859,7 @@ protected SCMRevision retrieve(@NonNull final String revision, @NonNull final Ta
//Since it was a full match then the shortMatch below will also match, so just skip it
continue;
}
for (GitSCMSourceContext.WantedOtherRef o : (Collection<GitSCMSourceContext.WantedOtherRef>)context.getOtherWantedRefs()) {
for (GitSCMSourceContext.RefNameMapping o : (Collection<GitSCMSourceContext.RefNameMapping>)context.getRefNameMappings()) {
if (o.matches(revision, name, rev)) {
candidateOtherRef = new GitRefSCMRevision(new GitRefSCMHead(revision, name), rev);
break;
@@ -1042,7 +1042,7 @@ public SCMRevision run(GitClient client, String remoteName) throws IOException,
}
}
if (context.wantOtherRefs() && (!name.startsWith(Constants.R_HEADS) || !name.startsWith(Constants.R_TAGS))) {
for (GitSCMSourceContext.WantedOtherRef o : (Collection<GitSCMSourceContext.WantedOtherRef>)context.getOtherWantedRefs()) {
for (GitSCMSourceContext.RefNameMapping o : (Collection<GitSCMSourceContext.RefNameMapping>)context.getRefNameMappings()) {
if (o.matches(name)) {
final String revName = o.getName(name);
if (revName != null) {
@@ -69,7 +69,7 @@
/**
* A list of other references to discover and search
*/
private Set<WantedOtherRef> wantedOtherRefs;
private Set<RefNameMapping> refNameMappings;
/**
* The name of the {@link GitTool} to use or {@code null} to use the default.
*/
@@ -124,15 +124,15 @@ public final boolean wantTags() {
* @return {@code true} if the {@link GitSCMSourceRequest} will need information about other refs.
*/
public final boolean wantOtherRefs() {
return wantedOtherRefs != null && !wantedOtherRefs.isEmpty();
return refNameMappings != null && !refNameMappings.isEmpty();
}

@NonNull
public Collection<WantedOtherRef> getOtherWantedRefs() {
if (wantedOtherRefs == null) {
public Collection<RefNameMapping> getRefNameMappings() {
if (refNameMappings == null) {
return Collections.emptySet();
} else {
return Collections.unmodifiableSet(wantedOtherRefs);
return Collections.unmodifiableSet(refNameMappings);
}
}

@@ -214,11 +214,11 @@ public C wantTags(boolean include) {
*/
@SuppressWarnings("unchecked")
@NonNull
public C wantOtherRef(WantedOtherRef other) {
if (wantedOtherRefs == null) {
wantedOtherRefs = new TreeSet<>();
public C wantOtherRef(RefNameMapping other) {
if (refNameMappings == null) {
refNameMappings = new TreeSet<>();
}
wantedOtherRefs.add(other);
refNameMappings.add(other);
return (C) this;
}

@@ -340,12 +340,12 @@ public R newRequest(@NonNull SCMSource source, TaskListener listener) {
return (R) new GitSCMSourceRequest(source, this, listener);
}

public static final class WantedOtherRef implements Comparable<WantedOtherRef> {
public static final class RefNameMapping implements Comparable<RefNameMapping> {
private final String ref;
private final String name;
private transient Pattern refPattern;

public WantedOtherRef(@NonNull String ref, @NonNull String name) {
public RefNameMapping(@NonNull String ref, @NonNull String name) {
this.ref = ref;
this.name = name;
}
@@ -372,7 +372,7 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

WantedOtherRef that = (WantedOtherRef) o;
RefNameMapping that = (RefNameMapping) o;

if (!ref.equals(that.ref)) return false;
return name.equals(that.name);
@@ -386,7 +386,7 @@ public int hashCode() {
}

@Override
public int compareTo(WantedOtherRef o) {
public int compareTo(RefNameMapping o) {
return Integer.compare(this.hashCode(), o != null ? o.hashCode() : 0);
}

@@ -108,7 +108,7 @@ private void setDefaultNameMapping() {
protected void decorateContext(SCMSourceContext<?, ?> context) {
GitSCMSourceContext c = (GitSCMSourceContext) context;
c.withRefSpec(getFullRefSpec());
c.wantOtherRef(new GitSCMSourceContext.WantedOtherRef(this.ref, this.nameMapping));
c.wantOtherRef(new GitSCMSourceContext.RefNameMapping(this.ref, this.nameMapping));
}

/**

0 comments on commit 36a307a

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