Skip to content

Commit f52ff4e

Browse files
committed
[github_pr_destination] Don't require context reference if pr_branch is set
This will allow copybara to succeed for the following origin: ``` git.origin( url = "https://github.com/google/copybara.git", ref = "b0f6c6bbb5828c95b2b1409b4e491865d969f679", ) ```
1 parent b0f6c6b commit f52ff4e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

java/com/google/copybara/git/GitHubPrDestination.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,18 @@ private String getPullRequestBranchName(
337337
return gitHubDestinationOptions.destinationPrBranch;
338338
}
339339
String contextReference = changeRevision.contextReference();
340-
// We could do more magic here with the change identity. But this is already complex so we
341-
// require a group identity either provided by the origin or the workflow (Will be implemented
342-
// later.
343-
checkCondition(contextReference != null,
344-
"git.github_pr_destination is incompatible with the current origin. Origin has to be"
345-
+ " able to provide the contextReference or use '%s' flag",
346-
GitHubDestinationOptions.GITHUB_DESTINATION_PR_BRANCH);
347-
String branchNameFromUser = getCustomBranchName(contextReference);
340+
341+
String branchNameFromUser = prBranch;
342+
if (prBranch == null) {
343+
// We could do more magic here with the change identity. But this is already complex so we
344+
// require a group identity either provided by the origin or the workflow (Will be implemented
345+
// later.
346+
checkCondition(contextReference != null,
347+
"git.github_pr_destination is incompatible with the current origin. Origin has to be"
348+
+ " able to provide the contextReference or use '%s' flag",
349+
GitHubDestinationOptions.GITHUB_DESTINATION_PR_BRANCH);
350+
branchNameFromUser = getCustomBranchName(contextReference);
351+
}
348352
String branchName =
349353
branchNameFromUser != null
350354
? branchNameFromUser

0 commit comments

Comments
 (0)