Deleting files produces empty commits
klieret opened this issue · comments
Describe the bug
Deleting a file produces empty commits instead of deleting them
To Reproduce
Run the following command on a test repository containing a README.md
(you can fork mine):
multi-gitter run "rm README.md" -R klieret/multi-gitter-delete-bug-demonstration -m "Remove file"
Expected behavior
I expect a commit that has README.md
deleted.
What happens instead
The output looks normal:
INFO[0000] Running on 1 repositories
INFO[0000] Cloning and running script repo=klieret/multi-gitter-delete-bug-demonstration
INFO[0000] Pushing changes to remote repo=klieret/multi-gitter-delete-bug-demonstration
INFO[0001] Creating pull request repo=klieret/multi-gitter-delete-bug-demonstration
Repositories with a successful run:
klieret/multi-gitter-delete-bug-demonstration #1
But you get a PR with an empty commit. Which is bad because the README.md
should be deleted, but also bad because empty commits shouldn't be added by multi-gitter.
Thanks for a concise repo :D This does indeed seems like a bug. I'm unable to repo, or fix right now as I don't have access to a dev computer. But can you try to run with --git-type=cmd and see if it gives the same result?
Will try later!
I was also wondering whether maybe using git rm
instead of plain rm
might solve this? (or a manual git add
afterwards)
Running git commands should not be needed, and could cause strange behavior.
Indeed git-type=cmd
solves this. So it's an issue with go-git?
Could be, or more likely how multi-gitter is using it. But one of the two guaranteed
Can't see anything obvious here:
multi-gitter/internal/git/gogit/git.go
Line 91 in 5dfd6d9
But will have to look closer when I have access to a computer:)
Seems that this is actually a go-git issue: go-git/go-git#223
There is a linked workaround that I will test later this week to see if it works (or if you want to try it out).
Added a fix here: #273 with a test that fails without the fix.
Included in release v0.42.3 🎉