sorenlouv / backport

A simple CLI tool that automates the process of backporting commits on a GitHub repo
https://github.com/sqren/backport/blob/main/docs/config-file-options.md
Apache License 2.0
241 stars 57 forks source link

Whatever I do i get a "branch is invalid or doesn't exist" #484

Open dpc opened 6 months ago

dpc commented 6 months ago

I'm trying to use backport locally for convenient backporting, but no matter what access token I give it I'm hitting:

$ npx backport --commit 516b25067b4bec1d1fb4fc075f85f3415433c767 --sourceBranch 23-12-11-just-backport-commit
repo: fedimint/fedimint

? Select commit chore: backport-commit
? Select branch releases/v0.2

Backporting to releases/v0.2:
✖ Pulling latest changes
The branch "releases/v0.2" is invalid or doesn't exist

Is there a -v flag or something where I could look at what is going on under the hood?

sorenlouv commented 6 months ago

Hi there,

What version of backport are you using? Try npx backport --version

sorenlouv commented 6 months ago

I think I found the issue. You are trying to backport a commit from the branch 23-12-11-just-backport-commit. This branch doesn't exist.

The error message is currently misleading. i'll add a fix to improve that.

Btw. I tried figuring out on which branch the commit lives, but it looks like it's an orphan: https://github.com/fedimint/fedimint/commit/516b25067b4bec1d1fb4fc075f85f3415433c767

dpc commented 6 months ago

The branch existed locally in my local repo, as the commit is in a private fork, so I couldn't really point at any upstream PR number. So I started with --commit but that immediately failed, so I tried --sourceBranch my local branch name and I it looked like it is kind of working as it was doing something before it failed at what looked like trying to push, but I guess I just confused myself.

I'd really love some --verbose flag that would print Fetching branch xyz, Checkout out abc, etc. I often work in weird setups and need to bend tools in all sorts of ways and being able to understand the inner-workings is very helpful.

sorenlouv commented 6 months ago

I'd really love some --verbose flag that would print Fetching branch xyz, Checkout out abc, etc. I often work in weird setups and need to bend tools in all sorts of ways and being able to understand the inner-workings is very helpful.

There are logs in ~/.backport/backport.info.log and ~/.backport/backport.debug.log. If you have jq installed you can read them like

tail -f ~/.backport/backport.info.log | jq
sorenlouv commented 6 months ago

The branch existed locally in my local repo, as the commit is in a private fork, so I couldn't really point at any upstream PR number

The way the backport tool works, is that it clones the repository into a temporary folder, and performans the git operations there. The commit you want to backport therefore needs to be available in the upstream repository - not just locally.

dpc commented 6 months ago

The way the backport tool works, is that it clones the repository into a temporary folder, and performans the git operations there. The commit you want to backport therefore needs to be available in the upstream repository - not just locally.

Is there any way to backport a PR/commit from a private fork to a public upstream one? Is it something that could be supported?

sorenlouv commented 6 months ago

Is there any way to backport a PR/commit from a private fork to a public upstream one? Is it something that could be supported?

I don't think so. Does Github even support this? If you have a private fork, of a public repo, can you create a pull request on the public repo, that references a change in the private repo? If not, I don't see how this should work.

dpc commented 6 months ago

Does Github even support this? If you have a private fork, of a public repo, can you create a pull request on the public repo, that references a change in the private repo? If not, I don't see how this should work.

I thought that backport fetches the PR, created a new branch, pushes it somewhere and creates a PR. The only difference in this workflow is that "fetches the PR" comes from some other repo than the original one, no?