This handles the case where a null error is passed into the Logger
without causing a null pointer dereference / segfault. There are
currently a couple places that invoke this function with a nil error and
were resulting in a segfault.
These fix the issues identified by the k/k inspired linter
configuration that we will be adding:
```
pkg/pid1/pid1.go:72:14: ST1005: error strings should not end with punctuation or newlines (stylecheck)
return 0, fmt.Errorf("unhandled exit status: 0x%x\n", status)
^
pkg/pid1/pid1.go:86:21: ST1005: error strings should not end with punctuation or newlines (stylecheck)
return false, 0, fmt.Errorf("wait4(): %w\n", err)
^
main.go:480:34: Error return value of `pflag.CommandLine.MarkDeprecated` is not checked (errcheck)
pflag.CommandLine.MarkDeprecated("branch", "use --ref instead")
^
main.go:483:34: Error return value of `pflag.CommandLine.MarkDeprecated` is not checked (errcheck)
pflag.CommandLine.MarkDeprecated("change-permissions", "use --group-write instead")
^
main.go:486:34: Error return value of `pflag.CommandLine.MarkDeprecated` is not checked (errcheck)
pflag.CommandLine.MarkDeprecated("dest", "use --link instead")
^
main.go:1897:16: Error return value of `io.WriteString` is not checked (errcheck)
io.WriteString(h, s)
^
main.go:555:2: ifElseChain: rewrite if-else to switch statement (gocritic)
if *flDeprecatedBranch != "" && (*flDeprecatedRev == "" || *flDeprecatedRev == "HEAD") {
^
```
The "origin" remote is implicitly used as the basis for relative-paths
in submodules. It's very subtly documented, and I have no idea if there
are other places where it is used. It seems git really expects it to
exist, so let's just do that.
To do this, we run the e2e test as a different user. To do that, we
need git-sync to make sure that everything is group accessible. To
clean up after the test, we need everything to be group writable. To do
that, we add a new flag: `--group-write`.
The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit
replaces the existing io/ioutil functions with their new definitions in
io and os packages.
[1]: https://golang.org/doc/go1.16#ioutil
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
* changed sendCompletedOnceMessageIfApplicable so that it kills thread
after executing
* moved logic for waiting on HookRunner into function defined in
HookRunner itself
- Renamed [x]HookChannel to [x]hookChannel for consistency
- Made hookChannels buffered chanels of size 1
- Added clarifying documentation and renamed functions expalining how I was
- ensuring that hooks execute at least once, assuming that main thread does not crash
- make sure chanels are not written to more than once
Resolved original issue by introducing a boolean chanel by which exechook runner can communicate with main thread.
Then introduced and used webhook executed-at-least-once chanel and added documentation explaining sections of of code
only executed when git-sync pulls for first time.
No difference in flags. Log output will now be JSON.
example:
{"logger":"","ts":"2021-11-24 11:19:46.340238","caller":{"file":"main.go","line":1031},"level":0,"msg":"cloning repo","origin":"https://github.com/thockin/git-sync","path":"/tmp/gt"}
1) Was calling Wait() on the child process, but also calling Wait4,
which would race, causing an occasional error or panic.
2) In testing (1), I observed occasional hangs. Tracing it down to a
SIGWINCH, which masked a SIGCHLD, causing it to hang. Both seem fixed.
Added a manual test script.
This detects when it is running as pid 1, and becomes an init process.
Specifically this means handling SIGCHLD and reaping processes
(otherwise they become zombies) and forwarding signals to "real"
process.
We fork and re-exec ourselves so that we only get *this* SIGCHLD for
orphaned processes (re-parented to 1) and not the real events from
running things like git or ssh.
Faster builds and versions from tags. Also use alpine as a base image. We
need alpine for other architectures...
Also change the --wait flag to take a float for sub-second waits.