Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the code is a bit confusing after this change.

When prBranch == null, we get branchNameFromUser == null (now the only reason to enter the if statement),

But then we call:

    if (prBranch == null) {
      return null;
    }
...

effectively returning null.

I would refactor this code to have something that makes sense overall.

Also, could you add a tests in GitHubPrDestinationTest?

Thanks for the contribution!!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed changes in #229

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