gruntwork-io / git-xargs

git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.
https://blog.gruntwork.io/introducing-git-xargs-an-open-source-tool-to-update-multiple-github-repos-753f9f3675ec
Apache License 2.0
944 stars 62 forks source link

git-xargs doesn't update existing PRs #109

Open jduan-highnote opened 1 year ago

jduan-highnote commented 1 year ago

Describe the bug First of all, I recently discovered this amazing tool and I've used it to open a bunch of PRs across a few repos. That worked amazingly!

Now I got some review feedback and I'm trying to update those PRs by using git-xargs again. Here's what I did:

git-xargs \
  --branch-name "test-branch1" \
  --commit-message "Upgrade jira-description-action to use node16" \
  --repos ~/repos.txt \
  --pull-request-title "SINF-522 Upgrade jira-description-action to use node16" \
  --pull-request-description "Because the latest version uses node 16" \
  --loglevel DEBUG \
  /tmp/2.sh

The intention is that I want git-xargs to run /tmp/2.sh to addresses the feedback on the existing PR branch(es) and push the changes. That's the behavior of git-xargs when the branch already exists. However, git-xargs seems to ignore the existing remote branch and creates a new local branch with the same name. When it tries to push the branch to remote, it will report this error:

Error="non-fast-forward update"

Why is git-xargs not making changes to the existing branch?

To Reproduce See above

// paste code snippets here

Expected behavior git-xargs should make changes to the existing branch.

Nice to have

Additional context Add any other context about the problem here.

navrkald commented 7 months ago

I can confirm the bug. I have checked as well the source code and bug is in logic of method checkoutLocalBranch which clones repository, then it creates on top of the remote repository HEAD (usually default branch is configured develop/master/main) new local branch and then it tries to pull remote brach, which might fail if it can't be fast forwarded from locally, created branch on top of HEAD, to remote branch. Instead code should try to checkout branch locally after clone repo and if it will fail then it should create new branch...