When git-sync fails to clone the git project, the ssh diagnostic message
is suppressed. It is sometimes helpful for debugging the cloning issue.
One example of the ssh dianostic message is
```
ssh: Could not resolve hostname ${REPO_HOST}: Name or service not known
```
This commit removes the `-q` flag from the ssh command to expose such
message.
* Avoid writing to /etc/password unless needed
Signed-off-by: Mac Chaffee <me@macchaffee.com>
* Use user.LookupId to check /etc/passwd
Signed-off-by: Mac Chaffee <me@macchaffee.com>
* Remove unused variables
Signed-off-by: Mac Chaffee <me@macchaffee.com>
This is a port of #431.
A new flag `--password-file` is added. This allows git-sync to read
password from file and this is considered as safer than reading from
env or flag directly.
Few more checks are added as well:
1. `--password` and `--password-file` can't be specified at the same
time.
2. If `--username` is specified, then one of `--password` or
`--password-file` must be specified.
When we fetch expecting a rev/hash to be present, defensively check and fail gracefully so that a subsequent sync would get it. Check for missing hash after a git fetch with shallow depth
They are using git-sync and have had a bunch of ideas for improvements.
I have had a hard time finding enough time to devote to this and they
offered to help.
This is to avoid wedge cases where the worktree was created but this function error'd without cleaning the worktree.
Next timearound, the sync loop fails to create the worktree and bails out.
We observed a case where due to #412, the next sync loop failed with this error:
" Run(git worktree add /repo/root/rev-nnnn origin/develop): exit status 128: { stdout: \"Preparing worktree (detached HEAD nnnn)\\n\", stderr: \"fatal: '/repo/root/rev-nnnn' already exists\\n\" }"
When endpoint returns non-200 status, include the body in the error
message since it can contain useful information for debugging. Also
defer closing the response body ReadCloser as this may have leaked in
the past.