fix: fix ENAMETOOLONG for too big commit messages #263
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.
This PR allows running
semantic-release
to reliably commit arbitrary big commit messages. The old way of adding a commit message was by passing it simply along as a command line argument togit commit -m ${message}
this will easily break for huge commit messages, depending on the platform:execa()
call to roughly 8 KBIn practice one can easily hit those limits by having a moderate number of changes during releases, because upstream in
semantic-release
for a default setup ofsemantic-release/changelog
,semantic-release/git
the generated changelog is added as a commit message.The fix is, that the message is not passed as an argument, but a temporary file containing the message will be created and the file will be passed instead.
There are now some additional implications; whenever something goes wrong, there is the possibility that temporary files are not deleted, however as
os.tmpdir()
is used, this is something that the OS should deal with. Furthermore this now will break, ifos.tmpdir()
is not writeable bysemantic-release
. However I think it is a fair assumption, thatos.tmpdir()
is writeable - although an additional check could be added.Whether this is a breaking change, this is left as
an exercise for the astute readersomething to be answerer by the maintainers. I'd say it is not, because it is behaving as intended. However this might break some pipelines, that have notos.tmpdir()
writeable. I tested it on an Azure DevOps Windows hosted agent and I am pretty sure™ that in a sane default™ setup of build agents this should not pose any problems.This is somehow related to: #91 (although I think the actual course for the problem there was the amout of changed files); at least it is giving the same error message.
There are further places in the code, where seemingly unrestricted data is passed via
execa()
that is suffering from the same problems (adding a lot of files via add), however fixing this is not so easy, becausegit add
does not support adding files from a "list file". Possible solutions would be a chunked adding (splitting the files by "length" and thus multiplegit add
calls) - however this has further implications. I'd rather fix those problems in another PR if the maintainers are fine with this approach (or suggesting sth. better).