Old way:
- ls-remote $ref $ref^{} and parse
- compare to current
- if changed, fetch
- update worktree
New way:
- fetch $ref
- compare to current
- if change, update worktree
The --ssh-key-file flag can be specified more than once and the
GITSYNC_SSH_KEY_FILE env var will be parsed like PATH.
Also adds e2e coverage for wrong-key and for multiple keys.
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") {
^
```
I believe we print a new line anyway from e.g. envInt, which calls fmt.Fprintln.
Found by staticcheck:
main.go:127:17: error strings should not end with punctuation or newlines (ST1005)
main.go:157:13: error strings should not end with punctuation or newlines (ST1005)
main.go:187:13: error strings should not end with punctuation or newlines (ST1005)
main.go:217:13: error strings should not end with punctuation or newlines (ST1005)
Fix a few misc linter issues:
main_test.go:750:7: Error return value is not checked (errcheck)
touch(dirPath)
^
main_test.go:759:7: Error return value is not checked (errcheck)
touch(filePath)
^
main_test.go:768:7: Error return value is not checked (errcheck)
touch(newfilePath)
^
main.go:2089:3: S1023: redundant `return` statement (gosimple)
return
^
main.go:1935:13: S1039: unnecessary use of fmt.Sprintf (gosimple)
sshCmd += fmt.Sprintf(" -o StrictHostKeyChecking=no")
^
main.go:1152:33: SA1016: os.Kill cannot be trapped (did you mean syscall.SIGTERM?) (staticcheck)
signal.Notify(c, os.Interrupt, os.Kill)
Previously, errors from askpass and credential storage were being
ignored, causing git clone/fetch to later error with hard-to-read
errors.
Now the error indicates the credential refresh as the problem, and
does not try to sync.
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.
This ensures we do not miss events. E.g.
before:
t0: hash changes to X
t1: send webhook(X), waiting for response
t2: hash changes to Y
t3: queue next webhook(Y) but can't send because previous is not done
t4: crash
t5: restart
t6: find repo at hash Y
no webhook(Y) was sent.
after:
t0: hash changes to X
t1: send webhook(X), waiting for response
t2: hash changes to Y
t3: queue next webhook(Y) but can't send because previous is not done
t4: crash
t5: restart
t6: find repo at hash Y
t7: send webhook(Y), waiting for response
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.
This plus the test should ensure no regressions. Git makes it tricky to do
some things on a remote that you would think to do on a local repo.
`ls-remote` gives me the info I need with only one test for "HEAD" vs anything
else.
I know this used to work. I must have broken it at some point. Manually
verified for HEAD and a real tag.
Also fix some logging so it is less chatty by default.
v2.0.2