Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[github_pr_destination] Don't require context reference if pr_branch is set #226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Yannic
Copy link
Contributor

@Yannic Yannic commented Mar 8, 2023

This will allow copybara to succeed for the following origin:

git.origin(
    url = "https://github.com/google/copybara.git",
    ref = "b0f6c6bbb5828c95b2b1409b4e491865d969f679",
)

…` is set

This will allow copybara to succeed for the following origin:

```
git.origin(
    url = "https://github.com/google/copybara.git",
    ref = "b0f6c6bbb5828c95b2b1409b4e491865d969f679",
)
```
@Yannic Yannic force-pushed the yannic-pr-branch-destination branch from f52ff4e to 6ba12d2 Compare March 8, 2023 12:00
Copy link

@petemounce petemounce left a comment

Choose a reason for hiding this comment

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

Thanks!

(Context; we're using copybara to automate vendoring of source-code into a monorepo, but don't always want to continuously track & sync upstream branches. Sometimes we just want to pin to specific revisions and deliberately change those as/when we want to take updates from upstreams. This is then conveniently wrapped up in a CI job that can be triggered when the choice to sync to a different revision happens and is reviewed).

(I don't know if my approve counts for anything, but there it is)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants