git --atomic fallback causes non-zero exit code
See original GitHub issueExpected Behavior
Commands triggering git push
should return exit code zero hosts running git <2.4.0, ie Azure DevOps 😦
Current Behavior
Commands using git push
without --atomic
support always return the exit code of the atomic request attempt on success.
Possible Solution
This appears to be because childProcess
sets process.exitCode
on error. https://github.com/lerna/lerna/blob/6cb8ab2d4af7ce25c812e8fb05cd04650105705f/core/child-process/index.js#L138
When the non-atomic fallback is triggered the exit code from the first attempt remains.
Resetting the exit code in the catch on atomic errors does fix this issue… but I’m not familiar enough to gauge the risk of race condition when doing so.
diff --git a/commands/version/lib/git-push.js b/commands/version/lib/git-push.js
index 35936398..a7f0de1e 100644
--- a/commands/version/lib/git-push.js
+++ b/commands/version/lib/git-push.js
@@ -25,6 +25,8 @@ function gitPush(remote, branch, opts) {
) {
// --atomic is only supported in git >=2.4.0, which some crusty CI environments deem unnecessary to upgrade.
// so let's try again without attempting to pass an option that is almost 5 years old as of this writing...
+ // reset process.exitCode set by childProcess on atomic failure
+ process.exitCode = 0;
log.warn("gitPush", error.stderr);
log.info("gitPush", "--atomic failed, attempting non-atomic push");
Steps to Reproduce (for bugs)
- Remote host using git <2.4.0
lerna publish patch -y
echo $?
Exit code will be non-zero even on command success.
Your Environment
Executable | Version |
---|---|
lerna --version |
4.0.0 |
npm --version |
7.3.0 |
yarn --version |
1.22.10 |
node --version |
15.5.0 |
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:5
Top Results From Across the Web
git-config Documentation - Git
This command will fail with non-zero status upon error. Some exit codes are: The section or key is invalid (ret=1),. no section or...
Read more >git push --atomic - Not failing - Stack Overflow
It seems from the diff here that there needs to be something on the remote server that will accept the atomic flag as...
Read more >modesetting: Allow Present flips with mismatched stride on atomic ...
A legacy non-atomic driver will return a non-zero error code, either -EINVAL for early atomic Linux versions 4.0 - 4.19 (or for non-atomic...
Read more >git-config(1) - FreeBSD
This command will fail with non-zero status upon error. ... is used to store a per-user configuration as fallback values for the .git/config...
Read more >git-config command man page - git-core-doc - ManKier
This command will fail with non-zero status upon error. ... is used to store a per-user configuration as fallback values for the .git/config...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@miluxmilux I had the same issue. I use
lerna version --no-push
andgit push --follow-tags origin HEAD:$(Build.SourceBranch)
instead. At least I don’t get false exitcode 1 😃Identical issue here, worrying how stale this issue is