[Bug] Bump commits ALL files
Description
Instead of committing just all files containing a version ALL changed files are committed (new ones are not just changed ones). This is not good if a change is not meant to be included in the release.
While this can be avoided by branching it should still behave different as git add . and git commit <whatever> is very carelessly.
Steps to reproduce
- Create repo and add cz config file
- Add
file1.txtandfile2.txt - stage and Commit
file1 cz bump(Behaves as expected)- Commit the adding of
file2 - Change the content of
file1and don't stage it cz bump
You will see that all changes of file1 are commited in the bump: 0.0.1 -> 0.0.2 commit
Desired behavior
When executing a cz bump
- Stash the changes and added files (staged and unstaged the same)
- Warn the user if he has Staged files because they will be merged with the unstaged ones when stashing
- Execute the bump
- Pop the stash
- Delete the stash
Environment
-
commitizen version:2.13.0
-
python version:Python 2.7.17
-
operating system:Linux
I'm not sure we'll fix this, for me is working as desired, and it would involve quite some work. Sorry.
First, it's not doing git add ., this would include untracked files, I would consider this dangerous.
It is doing git add -a, which includes (as you said) not staged files, but which are being tracked, excludes untracked.
I delegate responsibility of this to the developer, if you don't want this to happen either create a commit or stash before doing a bump.
For me it also works as a feature, because I'm allowed to include other changes into the bump commit, cheaply without having to manually add them (if they are being tracked already).
Would it help if this behavior is documented?
An alternative implementation without using stash:
- Remove
-afromgit add - Run
git addfor the config file + the files included inversion_files - If the user has manually run
git add <files>they would also be included
Again, I don't have plans to fix this, but contributions are welcome 👍🏻
What do you think about "auto stashing" where bevore any changes are written a stash is created and after the bump the using stash pop to restore pre-bump state.
This would also be in line with your "future plans" so you don't have to add files manually. Would such a contribution / PR be accepted? Maybe adding an option/setting to enable or disable auto stashing would be useful.
The "feature" at the moment not being documented is less of a problem for me but ist just one sentence so maybe worth it.
The "auto stashing" option sounds good to me as long as we do not set it as the default behavior. If we'd like to do so in the future, we'll need to bump a major version
I'm in as a positional argument as well. I'd like to see an implementation 👍🏻
Sadly my python skills are quite limited. If it was a language i am actually active in (Java, TS, C#) i could contribute.
Closing as the current behavior works well enough
Would it help if this behavior is documented?
Yes! I was a bit thrown off by this behaviour and ended up here because it is not intuitive at all that files are committed outside of the commit command.