Skip to content

Commit 5bc0c22

Browse files
authored
Use case-insensitive string comparisons for org
1 parent 2828ae2 commit 5bc0c22

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

buildSrc/src/main/java/CloneOrUpdateRelatedTask.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import java.net.HttpURLConnection;
44
import java.net.URI;
55
import java.net.URL;
6+
import java.util.Locale;
7+
import java.util.Objects;
68
import javax.inject.Inject;
79
import org.eclipse.jgit.lib.Config;
810
import org.eclipse.jgit.lib.ConfigConstants;
@@ -111,12 +113,27 @@ private void checkOrgBranch(File relatedRepoDir) {
111113
}
112114

113115
/**
114-
* A pair of {@code org} and {@code branch}
116+
* A pair of {@code org} and {@code branch}. Because GitHub organizations are case-insensitive,
117+
* {@code org} is compared using case-insensitive string comparisons.
115118
*
116119
* @param org a GitHub organization name
117120
* @param branch a branch name
118121
*/
119-
public record OrgBranch(String org, String branch) {}
122+
public record OrgBranch(String org, String branch) {
123+
124+
@Override
125+
public boolean equals(Object o) {
126+
if (!(o instanceof OrgBranch other)) {
127+
return false;
128+
}
129+
return org.equalsIgnoreCase(other.org) && branch.equals(other.branch);
130+
}
131+
132+
@Override
133+
public int hashCode() {
134+
return Objects.hash(org.toLowerCase(Locale.ROOT), branch);
135+
}
136+
}
120137

121138
/**
122139
* Find the org and branch of the remote tracking branch that is currently checked out in {@code

0 commit comments

Comments
 (0)