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.
1. If `--username` is specified, then one of `--password` or
`--password-file` must be specified.
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.
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.
The `git clone` command will create the root directory if it doesn't
exist, but if `git clone` fails, the root directory needs to be present
so that we can write the error to a file under the directory.
Wanted to finally tackle #54, I sidestepped the problem of how to handle the volume of flags that might be required by instead specifying a sparsecheckout file.
The workflow as I've had has been...
- Do a local sparse checkout, add the files you want ignored (or included on if you did a cone pattern https://git-scm.com/docs/git-sparse-checkout#_cone_pattern_set)
- Grab your .git/info/sparecheckout file, and reserve it for later use with this new flag
It's not quite as easy as specifying it all from a CLI, but I think it's a reasonable first pass.
Here are some logs of it being run on https://github.com/SpencerMalone/logstash-output-prometheus:
```
test-repo % cat sparseconfig
!/*
!/*/
README.md
test-repo % docker run --rm -d \
-v $(pwd)/git-data:/tmp/git \
-v $(pwd):/test \
docker.io/registry/git-sync:tag__linux_amd64 \
--repo=https://github.com/SpencerMalone/logstash-output-prometheus.git \
--branch=master \
--sparse-checkout-file=/test/sparseconfig
41494548dd64caf0ff8f7b75e4d3a86014cfaefc40ff31b14ba19accf99aa82f
test-repo % ls git-data/db86200b1ab158ce9ad403d06de2301b15333601
README.md
```
As you can see, I ignored everything but the `README.md`, and sure enough only got that file in my final checkout.