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
935 stars 62 forks source link

No PR opened, if branch is up to date #32

Closed radicarl closed 3 years ago

radicarl commented 3 years ago

Hello,

found something which is probably a bug or at least unexpected behavior.

If, for some reason the changes I made with git-xargs exists already in the branch on github, the tool prints the following errors and does not open a PR.

[git-xargs] DEBU[2021-04-27T08:45:41+02:00] Error pushing new branch to remote origin     Error="already up-to-date" Repo=room-management-example
[git-xargs] DEBU[2021-04-27T08:45:41+02:00] Error encountered while processing repo       Error="already up-to-date" Repo name=room-management-example

I run into this error, because I run my git-xargs command two times. The first time I run into an error on opening the PR. After fixing this, I run the command a second time and failed on the update. I had to delete the remote branch first. I think it the tool should not break on an "already up-to-date" message, because the state of the repository is like it should be, only the way to achived was different.

Think this is an edge case and nothing urgent.

brikis98 commented 3 years ago

I just hit the same issue. It actually pushes the code to the existing branch correctly, so the original PR gets updated, but then you get this error about failing to try to open the PR again. I'll take a look.

radicarl commented 3 years ago

Hey,

you are fast, too fast :) The problem I ran into, was that on the first run, no PR was openend (because of the hard coded master-branch, but could also be missing permissions or something else) and on the second run, git-xargs stopped because the push did not changed the remote branch. Updating the PR won't help in this case, because there is none.

I think you have to change the method pushLocalBranch and filter for the "already up-to-date"-Error

radicarl commented 3 years ago

Hello,

I tested 0.0.8 and still run in this issue. This time the tool stopped earlier, because the script does not change the local repository. So there was nothing to commit.

My Expectation is, that the tool opens a PR as long as the given branch differs from the default-branch.

brikis98 commented 3 years ago

I think that's a similar, but separate issue: detecting if (a) there is an existing branch in the remote but (b) no existing PR for that branch. Could you file a separate issue for that?

radicarl commented 3 years ago

done, see #39