Git development
 help / color / mirror / Atom feed
* Git pre-received hook not failing with exit code 1 correcly
@ 2024-01-21  1:57 Marc C
  2024-01-21 18:05 ` brian m. carlson
  0 siblings, 1 reply; 2+ messages in thread
From: Marc C @ 2024-01-21  1:57 UTC (permalink / raw)
  To: git

Heya!

I am trying to understand why my pre-publish hook does not exit with the
correct status code. 

I have a pre-publish script

```
#!/bin/sh
set -euo pipefail
echo "Testing nixos config"
nixos-rebuild dry-build
echo "Success"
```

Running it directly in my CLI, it acts like I would expect and return
exit code 1.

```
$ ./.git/hooks/pre-receive
Testing nixos config
building the system configuration...
error:
       … while calling the 'seq' builtin
       ....
       ...

$ echo "$?"
1
```

However, when running the script as a pre-receive hook, it is not
running the commands correctly and returns the wrong exit code. I get
the following:

```
remote: Testing nixos config
remote: building the system configuration...
remote: Success <-- ????
remote: error:
remote:        … while calling the 'seq' builtin
...
To myserver:/myrepo
   bffa94e..a14b3f6  main -> main
```

Any clue what I am missing? When running it as a pre-receive hook, the
failing command returns exit code 0. Running it in the CLI, it returns
exit code 1. It is Schrodinger's exit code.

Thank you so much for your help.

Sincerely,
Marc


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-21 18:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-21  1:57 Git pre-received hook not failing with exit code 1 correcly Marc C
2024-01-21 18:05 ` brian m. carlson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox