ejoffe / spr

Stacked Pull Requests on GitHub
MIT License
717 stars 65 forks source link

0.14.1 cannot find upstream branch #349

Closed jameskyle closed 10 months ago

jameskyle commented 11 months ago

I'm still seeing this issue, though it no longer overwrites the config.

❯ egrep "githubRemote|githubBranch" .spr.yml
githubRemote: origin
githubBranch: develop
❯ ls -l $(which git-spr)
lrwxr-xr-x@ 1 jkyle  admin  32 Aug  8 11:19 /usr/local/bin/git-spr -> ../Cellar/spr/0.14.1/bin/git-spr
❯ git branch -vv | grep 658
* ef-658-customer-config-filtering-features        5e6c0e3a0a [develop: ahead 1] ef-660: add code coverage to effected methods
❯ git spr update
error: unable to fetch remote branch info, using defaults> git rev-parse --show-toplevel
> git fetch
> git rebase origin/main --autostash
git error: fatal: invalid upstream 'origin/main'
kirilne commented 10 months ago

Happens for me as well

➜  infra-core git:(feature/kirilne/create_utils) ✗ cat .spr.yml
requireChecks: false
requireApproval: false
githubRemote: origin
githubBranch: master
➜  infra-core git:(feature/kirilne/create_utils) ✗ git spr update --detail
error: unable to fetch remote branch info, using defaults> git rev-parse --show-toplevel
> git fetch
> git rebase origin/main --autostash
git error: fatal: invalid upstream 'origin/main'
ConnorSinnott commented 10 months ago

+1 origin/master is not being detected. Could we re-add the option to override automated behavior via the config?

jameskyle commented 10 months ago

@ConnorSinnott I believe the reintroduction of githubBranch was supposed to reintroduce that feature.

So I think the current behavior is a bug.

jameskyle commented 10 months ago

@ejoffe any thoughts on this one?

ejoffe commented 10 months ago

Sorry, I was away for a bit. In v0.14.1 the method of getting remote branch was changed to be fetched from the git upstream branch. The advantage of this approach is that you can now have stacks targeted at different remote branches, and example use case we have is different environments like a staging or feature branch. This however unfortunately was not backwards compatible and broke older configs. This should be fixed in v0.14.2 now. Both the Repo config yaml and upstream is used for this configuration. If git upstream configuration is set for the branch, it will take precedence over the Repo config.

vlad-ivanov-name commented 10 months ago

@ejoffe thanks for the fix! out of curiosity -- how would one configure the remote branch properly before this fix? it didn't work for me on a fresh git clone where I created a branch from master with git switch -c

ejoffe commented 10 months ago

Set the upstream of the branch: git branch -u origin/master This still works in v0.14.2. So you can actually have different upstreams set per branch, not just one for the whole repo.

jameskyle commented 10 months ago

I'll give the upstream a shot. Seems reasonable. Thanks for the work and explanation!