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

Hub doesn't use my default base branch when executing pull-request cmd from worktrees #2484

Closed
csaska opened this issue Feb 27, 2020 · 2 comments · Fixed by #2489
Closed
Labels

Comments

@csaska
Copy link

csaska commented Feb 27, 2020

Command attempted:

HUB_VERBOSE=1 hub pull-request -p -m "Hub creating a PR to my default branch upstream/core_master"

More info:

$ hub --version
git version 2.21.1
hub version 2.14.1

I've used git remote set-head upstream core_master and git remote set-head origin core_master to set my default branches.

I noticed this issue originally added support for hub creating pull-requests to the defualt base branch when one wasn't specified using the -b flag.

What happened:

When I do hub pull-request from my clone, hub correctly chooses upstream/core_master as my default base branch; however, if I execute the same command in a worktree of this clone, hub defaults to using upstream/master.

From the worktree, I see the following:

{"base":"master","head":"pHWChip:feature/colt_testing","maintainer_can_modify":true,"title":"Testing"}

From the original clone, I see the following:

{"base":"core_master","head":"pHWChip:feature/colt-testing-2","maintainer_can_modify":true,"title":"Testing"}

Question:
Is this intended behavior? Is this a bug? Or am I requesting a new feature here?

@csaska csaska added the bug label Feb 27, 2020
@csaska csaska changed the title Hub doesn't correctly use my default base branch when executing cmd from worktrees Hub doesn't use my default base branch when executing pull-request cmd from worktrees Feb 28, 2020
@csaska
Copy link
Author

csaska commented Feb 28, 2020

It looks like the DefaultBranch is being initialized here. Perhaps on line 166 baseRemote == nil meaning line 168 is never executed?

https://github.com/github/hub/blob/b0db79dbf3988dd25c0053abc39a77fc92c46bfc/commands/pull_request.go#L168

edit: that is not the issue. I think the issue is that a worktree won't have .git dir so func BranchAtRef is not finding any references.

@csaska
Copy link
Author

csaska commented Feb 28, 2020

I can continue to dig through this code and submit a PR.

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