Run example with ssh keys from host: docker run -d --restart
unless-stopped --name gitwatch -v /root/.ssh/:/root/.ssh/ -v
/opt/repo_to_sync/:/repo -v /root/.gitconfig:/root/.gitconfig
salanki:gitwatch -r origin /repo
The call to `git add` for directories previously used the argument `.` while
being in the target directory. In current Git versions, this produces a warning
about the upcoming changes to `git add` behavior.
To remove this warning and make `git add` behave like we want it, now and in
coming Git versions, we added the `--all` switch to the call (as suggested in
the aforementioned warning). This will include removals as well as additions in
the index.
As detailed in #14, this improves usage of inotifywait: instead of calling inw
once per loop-run, it is launched once and its output piped into this script.
To facilitate this in an economic manner, a sleep period after a captured event
is added (it acts exactly as it did before this change). Should new events
occur while a waiting period is already running, that sleep process is killed
and a new one started. This groups together rapid events. The -s switch keeps
its functionality.
As mentioned in the issue, a big credit goes out to @datag, since the idea and
structure for this feature are taken from
datag/confcan@bcff79bc77.
Also fixes quoting (and quote-parsing) issues in a few places. These became
apparent in the inotifywait call (which is prepared as a string, from which
quotes arguments are not processed like normal unless `eval` is used). Testing
revealed a few quoting weaknesses in other places, where a path containing
whitespace would cause errors. Most of these should be fixed for now.
Closes#14.
Move checking and construction of push command out of main loop so construction
is only done once (push command does not change during script execution.