Skip to content

Commit 44ca710

Browse files
committed
Correct "Pull Request" Abbreviation in Class Names
In 'GitHubPROrigin.java' and 'GitHubPRIntegrateLabel.java' it was abbreviated as 'PR' instead of "Pr'. This is inconsistent with how it was abbreviated elsewhere in the project. PiperOrigin-RevId: 373186716 Change-Id: Idde4e68760a883ec60a8a45c03ba32d4be87b9fb
1 parent a84ac52 commit 44ca710

File tree

6 files changed

+57
-57
lines changed

6 files changed

+57
-57
lines changed

java/com/google/copybara/git/GitHubPRIntegrateLabel.java renamed to java/com/google/copybara/git/GitHubPrIntegrateLabel.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* <p>Where SHA-1 is optional: If present it means to integrate the specific SHA-1. Otherwise the
3535
* head of the PR is used.
3636
*/
37-
class GitHubPRIntegrateLabel implements IntegrateLabel {
37+
class GitHubPrIntegrateLabel implements IntegrateLabel {
3838

3939
private static final Pattern LABEL_PATTERN =
4040
Pattern.compile(
@@ -49,7 +49,7 @@ class GitHubPRIntegrateLabel implements IntegrateLabel {
4949
@Nullable
5050
private final String sha1;
5151

52-
GitHubPRIntegrateLabel(GitRepository repository, GeneralOptions generalOptions, String projectId,
52+
GitHubPrIntegrateLabel(GitRepository repository, GeneralOptions generalOptions, String projectId,
5353
long prNumber, String originBranch, @Nullable String sha1) {
5454
this.repository = Preconditions.checkNotNull(repository);
5555
this.generalOptions = Preconditions.checkNotNull(generalOptions);
@@ -60,11 +60,11 @@ class GitHubPRIntegrateLabel implements IntegrateLabel {
6060
}
6161

6262
@Nullable
63-
static GitHubPRIntegrateLabel parse(String str, GitRepository repository,
63+
static GitHubPrIntegrateLabel parse(String str, GitRepository repository,
6464
GeneralOptions generalOptions) {
6565
Matcher matcher = LABEL_PATTERN.matcher(str);
6666
return matcher.matches()
67-
? new GitHubPRIntegrateLabel(repository, generalOptions,
67+
? new GitHubPrIntegrateLabel(repository, generalOptions,
6868
matcher.group(1),
6969
Long.parseLong(matcher.group(2)),
7070
matcher.group(3),

java/com/google/copybara/git/GitHubPROrigin.java renamed to java/com/google/copybara/git/GitHubPrOrigin.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
/**
8585
* A class for reading GitHub Pull Requests
8686
*/
87-
public class GitHubPROrigin implements Origin<GitRevision> {
87+
public class GitHubPrOrigin implements Origin<GitRevision> {
8888

8989
static final int RETRY_COUNT = 3;
9090

@@ -131,7 +131,7 @@ public class GitHubPROrigin implements Origin<GitRevision> {
131131
private final GitHubHost ghHost;
132132
private final GitHubPrOriginOptions gitHubPrOriginOptions;
133133

134-
GitHubPROrigin(
134+
GitHubPrOrigin(
135135
String url,
136136
boolean useMerge,
137137
GeneralOptions generalOptions,
@@ -420,7 +420,7 @@ private GitRevision getRevisionForPR(String project, PullRequest prData)
420420
GitRevision gitRevision = getRepository().resolveReference(refForMigration);
421421

422422
String headPrSha1 = getRepository().resolveReference(LOCAL_PR_HEAD_REF).getSha1();
423-
String integrateLabel = new GitHubPRIntegrateLabel(getRepository(), generalOptions,
423+
String integrateLabel = new GitHubPrIntegrateLabel(getRepository(), generalOptions,
424424
project, prNumber,
425425
prData.getHead().getLabel(),
426426
// The integrate SHA has to be HEAD of the PR not the merge ref, even if use_merge = True
@@ -734,7 +734,7 @@ abstract static class ApproverState {
734734

735735
public static ApproverState create(
736736
boolean shouldMigrate, ImmutableList<Review> rejectedReviews) {
737-
return new AutoValue_GitHubPROrigin_ApproverState(
737+
return new AutoValue_GitHubPrOrigin_ApproverState(
738738
shouldMigrate,
739739
rejectedReviews.stream().collect(ImmutableListMultimap.toImmutableListMultimap(
740740
r -> r.getUser().getLogin(), r -> r.getAuthorAssociation().toString())));

java/com/google/copybara/git/GitIntegrateChanges.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private void doIntegrate(GitRepository repository, GeneralOptions generalOptions
109109
try (ProfilerTask ignore = generalOptions.profiler().start("integrate",
110110
ImmutableMap.of("URL", label.getValue()))) {
111111
generalOptions.console().progress("Integrating change from " + label.getValue());
112-
IntegrateLabel integrateLabel = GitHubPRIntegrateLabel.parse(label.getValue(), repository,
112+
IntegrateLabel integrateLabel = GitHubPrIntegrateLabel.parse(label.getValue(), repository,
113113
generalOptions);
114114
if (integrateLabel == null) {
115115
integrateLabel = GerritIntegrateLabel.parse(label.getValue(), repository,

java/com/google/copybara/git/GitModule.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
import static com.google.copybara.config.SkylarkUtil.checkNotEmpty;
2121
import static com.google.copybara.config.SkylarkUtil.convertFromNoneable;
2222
import static com.google.copybara.config.SkylarkUtil.stringToEnum;
23-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_BASE_BRANCH;
24-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_BASE_BRANCH_SHA1;
25-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_ASSIGNEE;
26-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_BODY;
27-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_HEAD_SHA;
28-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_REVIEWER_APPROVER;
29-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_REVIEWER_OTHER;
30-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_TITLE;
31-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_URL;
32-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_USER;
33-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_USE_MERGE;
23+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_BASE_BRANCH;
24+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_BASE_BRANCH_SHA1;
25+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_ASSIGNEE;
26+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_BODY;
27+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_HEAD_SHA;
28+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_REVIEWER_APPROVER;
29+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_REVIEWER_OTHER;
30+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_TITLE;
31+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_URL;
32+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_USER;
33+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_USE_MERGE;
3434
import static com.google.copybara.git.LatestVersionSelector.VersionElementType.ALPHABETIC;
3535
import static com.google.copybara.git.LatestVersionSelector.VersionElementType.NUMERIC;
3636
import static com.google.copybara.git.github.api.GitHubEventType.WATCHABLE_EVENTS;
@@ -60,8 +60,8 @@
6060
import com.google.copybara.git.GerritDestination.ChangeIdPolicy;
6161
import com.google.copybara.git.GerritDestination.NotifyOption;
6262
import com.google.copybara.git.GitDestination.WriterImpl.DefaultWriteHook;
63-
import com.google.copybara.git.GitHubPROrigin.ReviewState;
64-
import com.google.copybara.git.GitHubPROrigin.StateFilter;
63+
import com.google.copybara.git.GitHubPrOrigin.ReviewState;
64+
import com.google.copybara.git.GitHubPrOrigin.StateFilter;
6565
import com.google.copybara.git.GitIntegrateChanges.Strategy;
6666
import com.google.copybara.git.GitOrigin.SubmoduleStrategy;
6767
import com.google.copybara.git.LatestVersionSelector.VersionElementType;
@@ -695,7 +695,7 @@ public GitOrigin gerritOrigin(
695695
+ "Implicit labels that can be used/exposed:\n"
696696
+ "\n"
697697
+ " - "
698-
+ GitHubPROrigin.GITHUB_PR_NUMBER_LABEL
698+
+ GitHubPrOrigin.GITHUB_PR_NUMBER_LABEL
699699
+ ": The pull request number if the"
700700
+ " reference passed was in the form of `https://github.com/project/pull/123`, "
701701
+ " `refs/pull/123/head` or `refs/pull/123/master`.\n"
@@ -914,7 +914,7 @@ public GitOrigin gerritOrigin(
914914
useStarlarkThread = true)
915915
@UsesFlags(GitHubPrOriginOptions.class)
916916
@DocDefault(field = "review_approvers", value = "[\"COLLABORATOR\", \"MEMBER\", \"OWNER\"]")
917-
public GitHubPROrigin githubPrOrigin(
917+
public GitHubPrOrigin githubPrOrigin(
918918
String url,
919919
Boolean merge,
920920
Sequence<?> requiredLabels, // <String>
@@ -962,7 +962,7 @@ public GitHubPROrigin githubPrOrigin(
962962
reviewApprovers = ImmutableSet.copyOf(approvers);
963963
}
964964
GitHubPrOriginOptions prOpts = options.get(GitHubPrOriginOptions.class);
965-
return new GitHubPROrigin(
965+
return new GitHubPrOrigin(
966966
fixHttp(url, thread.getCallerLocation()),
967967
prOpts.overrideMerge != null ? prOpts.overrideMerge : merge,
968968
options.get(GeneralOptions.class),

javatests/com/google/copybara/git/GitDestinationIntegrateTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public void testGitHubSemiFakeMerge() throws ValidationException, IOException, R
371371
GitDestination destination = destinationWithDefaultIntegrates();
372372
GitLogEntry previous = createBaseDestinationChange(destination);
373373

374-
GitHubPRIntegrateLabel labelObj = new GitHubPRIntegrateLabel(repo, options.general,
374+
GitHubPrIntegrateLabel labelObj = new GitHubPrIntegrateLabel(repo, options.general,
375375
"example/test_repo", 20, "some_user:1234-foo.bar.baz%3", secondChange.getSha1());
376376

377377
assertThat(labelObj.getProjectId()).isEqualTo("example/test_repo");
@@ -414,7 +414,7 @@ public void testGitHubSemiFakeMerge() throws ValidationException, IOException, R
414414
.filter(e -> e.getType() == MessageType.WARNING)
415415
.collect(Collectors.toList())).isEmpty();
416416

417-
label = new GitHubPRIntegrateLabel(repo, options.general,
417+
label = new GitHubPrIntegrateLabel(repo, options.general,
418418
"example/test_repo", 20, "some_user:branch", firstChange.getSha1()).toString();
419419
assertThat(label).isEqualTo("https://github.com/example/test_repo/pull/20"
420420
+ " from some_user:branch " + firstChange.getSha1());

javatests/com/google/copybara/git/GitHubPrOriginTest.java

+30-30
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
package com.google.copybara.git;
1818

1919
import static com.google.common.truth.Truth.assertThat;
20-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_BASE_BRANCH;
21-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_BASE_BRANCH_SHA1;
22-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_ASSIGNEE;
23-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_BODY;
24-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_HEAD_SHA;
25-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_NUMBER_LABEL;
26-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_TITLE;
27-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_URL;
28-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_USER;
29-
import static com.google.copybara.git.GitHubPROrigin.GITHUB_PR_USE_MERGE;
20+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_BASE_BRANCH;
21+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_BASE_BRANCH_SHA1;
22+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_ASSIGNEE;
23+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_BODY;
24+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_HEAD_SHA;
25+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_NUMBER_LABEL;
26+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_TITLE;
27+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_URL;
28+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_USER;
29+
import static com.google.copybara.git.GitHubPrOrigin.GITHUB_PR_USE_MERGE;
3030
import static com.google.copybara.testing.git.GitTestUtil.getGitEnv;
3131
import static com.google.copybara.testing.git.GitTestUtil.mockResponse;
3232
import static com.google.copybara.testing.git.GitTestUtil.mockResponseAndValidateRequest;
@@ -206,7 +206,7 @@ public void testGitResolvePullRequestRawRef() throws Exception {
206206
public void testGitResolveSha1() throws Exception {
207207
mockPullRequestAndIssue("open", 123);
208208

209-
GitHubPROrigin origin = githubPrOrigin(
209+
GitHubPrOrigin origin = githubPrOrigin(
210210
"url = 'https://github.com/google/example'");
211211
checkResolve(origin, "refs/pull/123/head", 123);
212212

@@ -526,7 +526,7 @@ public void testChanges() throws Exception {
526526

527527
mockPullRequestAndIssue("open", 123);
528528

529-
GitHubPROrigin origin = githubPrOrigin(
529+
GitHubPrOrigin origin = githubPrOrigin(
530530
"url = 'https://github.com/google/example'");
531531

532532
Reader<GitRevision> reader = origin.newReader(Glob.ALL_FILES, authoring);
@@ -571,7 +571,7 @@ public void testCheckout() throws Exception {
571571

572572
mockPullRequestAndIssue("open", 123);
573573

574-
GitHubPROrigin origin = githubPrOrigin(
574+
GitHubPrOrigin origin = githubPrOrigin(
575575
"url = 'https://github.com/google/example'",
576576
"baseline_from_branch = True");
577577

@@ -753,15 +753,15 @@ public void testReviewApproversDescription() throws ValidationException {
753753
public void testReviewApprovers() throws Exception {
754754
GitRevision noReviews = checkReviewApprovers();
755755
assertThat(noReviews.associatedLabels())
756-
.doesNotContainKey(GitHubPROrigin.GITHUB_PR_REVIEWER_APPROVER);
756+
.doesNotContainKey(GitHubPrOrigin.GITHUB_PR_REVIEWER_APPROVER);
757757
assertThat(noReviews.associatedLabels())
758-
.doesNotContainKey(GitHubPROrigin.GITHUB_PR_REVIEWER_OTHER);
758+
.doesNotContainKey(GitHubPrOrigin.GITHUB_PR_REVIEWER_OTHER);
759759

760760
GitRevision any = checkReviewApprovers("review_state = 'ANY'");
761761

762-
assertThat(any.associatedLabels().get(GitHubPROrigin.GITHUB_PR_REVIEWER_APPROVER))
762+
assertThat(any.associatedLabels().get(GitHubPrOrigin.GITHUB_PR_REVIEWER_APPROVER))
763763
.containsExactly("APPROVED_MEMBER", "COMMENTED_OWNER", "APPROVED_COLLABORATOR");
764-
assertThat(any.associatedLabels().get(GitHubPROrigin.GITHUB_PR_REVIEWER_OTHER))
764+
assertThat(any.associatedLabels().get(GitHubPrOrigin.GITHUB_PR_REVIEWER_OTHER))
765765
.containsExactly("COMMENTED_OTHER");
766766

767767
EmptyChangeException e =
@@ -781,24 +781,24 @@ public void testReviewApprovers() throws Exception {
781781
GitRevision hasReviewers = checkReviewApprovers("review_state = 'ANY_COMMIT_APPROVED'",
782782
"review_approvers = [\"MEMBER\", \"OWNER\"]");
783783

784-
assertThat(hasReviewers.associatedLabels().get(GitHubPROrigin.GITHUB_PR_REVIEWER_APPROVER))
784+
assertThat(hasReviewers.associatedLabels().get(GitHubPrOrigin.GITHUB_PR_REVIEWER_APPROVER))
785785
.containsExactly("APPROVED_MEMBER", "COMMENTED_OWNER");
786-
assertThat(hasReviewers.associatedLabels().get(GitHubPROrigin.GITHUB_PR_REVIEWER_OTHER))
786+
assertThat(hasReviewers.associatedLabels().get(GitHubPrOrigin.GITHUB_PR_REVIEWER_OTHER))
787787
.containsExactly("COMMENTED_OTHER", "APPROVED_COLLABORATOR");
788788

789789
GitRevision anyCommitApproved = checkReviewApprovers("review_state = 'HAS_REVIEWERS'",
790790
"review_approvers = [\"OWNER\"]");
791791

792-
assertThat(anyCommitApproved.associatedLabels().get(GitHubPROrigin.GITHUB_PR_REVIEWER_APPROVER))
792+
assertThat(anyCommitApproved.associatedLabels().get(GitHubPrOrigin.GITHUB_PR_REVIEWER_APPROVER))
793793
.containsExactly("COMMENTED_OWNER");
794-
assertThat(anyCommitApproved.associatedLabels().get(GitHubPROrigin.GITHUB_PR_REVIEWER_OTHER))
794+
assertThat(anyCommitApproved.associatedLabels().get(GitHubPrOrigin.GITHUB_PR_REVIEWER_OTHER))
795795
.containsExactly("APPROVED_MEMBER", "COMMENTED_OTHER", "APPROVED_COLLABORATOR");
796796
}
797797

798798

799799
@Test
800800
public void testHttprUrl() throws Exception {
801-
GitHubPROrigin val =
801+
GitHubPrOrigin val =
802802
skylark.eval(
803803
"origin", "origin = git.github_pr_origin(url = 'http://github.com/google/example')\n");
804804
assertThat(val.describe(Glob.ALL_FILES).get("url"))
@@ -829,7 +829,7 @@ public void requiredCheckRuns() throws Exception {
829829

830830
@Test
831831
public void testDescribeBranch() throws Exception {
832-
GitHubPROrigin val =
832+
GitHubPrOrigin val =
833833
skylark.eval(
834834
"origin", "origin = git.github_pr_origin("
835835
+ "url = 'http://github.com/google/example', branch = 'dev')\n");
@@ -903,12 +903,12 @@ private GitRevision checkReviewApprovers(String... configLines)
903903
Strings.repeat("0", 40))
904904
))));
905905

906-
GitHubPROrigin origin = createGitHubPrOrigin(configLines);
906+
GitHubPrOrigin origin = createGitHubPrOrigin(configLines);
907907

908908
return origin.resolve("123");
909909
}
910910

911-
private GitHubPROrigin createGitHubPrOrigin(String... configLines) throws ValidationException {
911+
private GitHubPrOrigin createGitHubPrOrigin(String... configLines) throws ValidationException {
912912
return skylark.eval("origin", "origin = "
913913
+ "git.github_pr_origin(\n"
914914
+ " url = 'https://github.com/google/example',\n"
@@ -957,7 +957,7 @@ public void testMerge() throws Exception {
957957
remote.simpleCommand("update-ref", GitHubUtil.asMergeRef(123), remote.parseRef("primary"));
958958

959959

960-
GitHubPROrigin origin =
960+
GitHubPrOrigin origin =
961961
githubPrOrigin(
962962
"url = 'https://github.com/google/example'",
963963
"branch = 'primary'",
@@ -1009,7 +1009,7 @@ public void testCheckout_noMergeRef() throws Exception {
10091009
mockPullRequestAndIssue("open", 123);
10101010

10111011
// Now try with merge ref
1012-
GitHubPROrigin origin = githubPrOrigin(
1012+
GitHubPrOrigin origin = githubPrOrigin(
10131013
"url = 'https://github.com/google/example'",
10141014
"use_merge = True");
10151015

@@ -1051,7 +1051,7 @@ public void testCheckout_noMergeRef_withForce() throws Exception {
10511051

10521052
mockPullRequestAndIssue("open", "main", 123, /*mergeable = */ true);
10531053

1054-
GitHubPROrigin origin =
1054+
GitHubPrOrigin origin =
10551055
githubPrOrigin("url = 'https://github.com/google/example'", "use_merge = True");
10561056

10571057
assertThat(origin.resolve("123").getSha1())
@@ -1074,7 +1074,7 @@ public void testCheckout_noMergeRef_withForce() throws Exception {
10741074
assertThat(origin.resolve("123").associatedLabel(GITHUB_PR_USE_MERGE)).containsExactly("false");
10751075
}
10761076

1077-
private void checkResolve(GitHubPROrigin origin, String reference, int prNumber)
1077+
private void checkResolve(GitHubPrOrigin origin, String reference, int prNumber)
10781078
throws RepoException, IOException, ValidationException {
10791079
GitRepository remote = gitUtil.mockRemoteRepo("github.com/google/example");
10801080
addFiles(remote, "first change", ImmutableMap.<String, String>builder()
@@ -1113,7 +1113,7 @@ private GitRepository withTmpWorktree(GitRepository remote) throws IOException {
11131113
return remote.withWorkTree(Files.createTempDirectory("temp"));
11141114
}
11151115

1116-
private GitHubPROrigin githubPrOrigin(String... lines) throws ValidationException {
1116+
private GitHubPrOrigin githubPrOrigin(String... lines) throws ValidationException {
11171117
return skylark.eval("r", "r = git.github_pr_origin("
11181118
+ " " + Joiner.on(",\n ").join(lines) + ",\n)");
11191119
}

0 commit comments

Comments
 (0)