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

Cannot open new pull requests H p #358

Open
se7entyse7en opened this issue Aug 6, 2018 · 8 comments
Open

Cannot open new pull requests H p #358

se7entyse7en opened this issue Aug 6, 2018 · 8 comments
Labels
bug describes a defect in supported/advertised functionality unconfirmed has not been reproduced by a maintainer

Comments

@se7entyse7en
Copy link

Hi, first of all thanks for this awesome project! I was using magithub on mac and everything was working flawlessly. Now at work I'm using it on ubuntu and for some reason I cannot open new pull requests (using H p) as it always complains: Nothing on remote yet; have you pushed your branch? Aborting. Is this due to a misconfiguration?

@vermiculus
Copy link
Owner

I'm assuming you did push the branch before trying to open the PR? Assuming you still have the branch around (or a branch that can reproduce this issue; feel free to use vermiculus/my-new-repository as a testing ground), can you provide your .git/config?

@vermiculus vermiculus added bug describes a defect in supported/advertised functionality unconfirmed has not been reproduced by a maintainer labels Sep 8, 2018
@se7entyse7en
Copy link
Author

se7entyse7en commented Sep 13, 2018

Hi @vermiculus, sorry for late reply, it was happening for every branch, and yes I the branch was pushed on origin. Anyway here's my .git/config:

[core]
    repositoryformatversion = 0
    filemode = true
	    bare = false
    logallrefupdates = true
[remote "origin"]
    url = git@github.com:a-user/a-project.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "develop"]
    remote = origin
    merge = refs/heads/develop
[branch "a-branch"]
    remote = origin
    merge = refs/heads/a-branch
[branch "master"]
    remote = origin
    merge = refs/heads/master

I solved it by adding:

[remote]
    pushDefault = origin

@vermiculus
Copy link
Owner

Ah, yes; this is working as designed, though I am a little confused: does magit know to push a-branch to origin? I thought when you pushed a branch, it sets pushDefault.

If that's not the case, I can add an (or …) for using branch.remote if branch.pushDefault isn't defined.

@se7entyse7en
Copy link
Author

Honestly I don't know git at this low level, but no it doesn't seem to set pushDefault on a per-branch basis even after the first push. May it depend on the git version? If you could add the fallback to branch.remote it would be awesome.

@vermiculus
Copy link
Owner

I'm not sure. @tarsius, do you have any wisdom on how pushDefault is set? Is this a git thing or a magit thing?

@tarsius
Copy link
Contributor

tarsius commented Sep 14, 2018

Git respects that variable but never sets it. A few Magit commands offer to set it unless configured otherwise.

@vermiculus
Copy link
Owner

vermiculus commented Sep 14, 2018

I'm trying to get the upstream remote. Would I be correct in saying that branch.pushDefault should be preferred, but branch.remote could be a fallback?

Edit

More specifically I'm trying to get the remote tracking branch.

@tarsius
Copy link
Contributor

tarsius commented Sep 14, 2018

I am not sure what you are asking for, so I have to be quite explicit.

In order to open a pull request you have to tell github about two branches: the source branch and the target branch. Obviously both of these branches have to be located inside a github remote (possibly but not necessarily the same one), because github doesn't have access to the repository on your own machine.

I assume that the first thing that you ask the user is "What branch would you like to be merged?" and that you default to the current branch.

But again, this has to be a branch on a github remote, so you have to determine the remote branch that corresponds to the selected local branch (*), not actually the current branch. To determine that branch you should use (format "%s/%s" (magit-get-push-remote) (magit-current-branch), provided magit-get-push-remote doesn't return nil obviously. If the user selects another local branch, then use (format "%s/%s" (magit-get-push-remote branch) branch).

Lets assume that's non-nil. Now you have to determine the branch into which that is supposed to be merged. magit-get-upstream-branch may return a local or a remote branch, depending on what the user prefers. If it is a local branch, then do something similar to what magit-get-indirect-upstream-branch does to get the corresponding remote branch.

If the push remote for the selected source branch is not set, then you have to resort to heuristics (e.g. if only one REMOTE/foo exists for foo, then use that). You can definitely not use the upstream branch, because then you would end up asking to merge e.g. origin/master into origin/master itself.

All of this works well if the user has embraced The Two Remotes. Otherwise it won't. (I am planning to implement forge-create-pullreq over the weekend or so, and while I am not sure yet about it I will probably insist on a properly configured triangular workflow and else fall back to asking the user to provide everything explicitly without attempting to guess any defaults. I recommend you do that too.)

(*) Of course you could also ask for a remote branch instead. But that might actually complicate matters because now you have to determine the local branch that corresponds to that remote branch before you can use the upstream of that local branch as the (default) target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug describes a defect in supported/advertised functionality unconfirmed has not been reproduced by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants