Skip to content

Commit

Permalink
[github_pr_destination] Don't require context reference if `pr_branch…
Browse files Browse the repository at this point in the history
…` is set

This will allow copybara to succeed for the following origin:

```
git.origin(
    url = "https://github.com/google/copybara.git",
    ref = "b0f6c6bbb5828c95b2b1409b4e491865d969f679",
)
```
  • Loading branch information
Yannic committed Mar 8, 2023
1 parent b0f6c6b commit 6ba12d2
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions java/com/google/copybara/git/GitHubPrDestination.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,18 @@ private String getPullRequestBranchName(
return gitHubDestinationOptions.destinationPrBranch;
}
String contextReference = changeRevision.contextReference();
// We could do more magic here with the change identity. But this is already complex so we
// require a group identity either provided by the origin or the workflow (Will be implemented
// later.
checkCondition(contextReference != null,
"git.github_pr_destination is incompatible with the current origin. Origin has to be"
+ " able to provide the contextReference or use '%s' flag",
GitHubDestinationOptions.GITHUB_DESTINATION_PR_BRANCH);
String branchNameFromUser = getCustomBranchName(contextReference);

String branchNameFromUser = prBranch;
if (branchNameFromUser == null) {
// We could do more magic here with the change identity. But this is already complex so we
// require a group identity either provided by the origin or the workflow (Will be implemented
// later.
checkCondition(contextReference != null,
"git.github_pr_destination is incompatible with the current origin. Origin has to be"
+ " able to provide the contextReference or use '%s' flag",
GitHubDestinationOptions.GITHUB_DESTINATION_PR_BRANCH);
branchNameFromUser = getCustomBranchName(contextReference);
}
String branchName =
branchNameFromUser != null
? branchNameFromUser
Expand Down

0 comments on commit 6ba12d2

Please sign in to comment.