Use git cmd to add CHANGELOG.md in merge script #3350
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problems
Initially I only wanted to fix this one:
But during merge of #3349 I accidentally committed a CHANGELOG.md with all file endings replaced with CRLF, due to the following problem:
gitpython-developers/GitPython#1189
GitPython's
repo.index.add()
doesn't respectcore.autocrlf
. Thus on Windows any files added to the index using this function will have their line endings messed up in the repository.Changes
Now we use
repo.git.add()
, which makes GitPython run thegit add
command using the binary.Here's where this happens, because I was curious:
https://github.com/gitpython-developers/GitPython/blob/651a81ded00eb993977bcdc6d65f157c751edb02/git/cmd.py#L540-L546
This also seems to solve the above exception, since the git binary understands POSIX paths on Windows.
Regardless I still replaced the
.as_posix()
withstr()
(which always returns the path formatted according to the current OS' standards, so double backslash on Windows), because it feels cleaner and more future proof.Slowly but surely we replace all actual GItPython usages with a call-through to the git binary...