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.
Due to the usage of the branch argument (customizable by the -b switch) in the
push command, the <branch> argument previously would push from the so-named
local branch. Since all commits happen on the currently active branch (if any),
that doesn't make much sense, since any branch other than the checked-out one
will probably not get any changes. The effect of the -b switch is thus changed
to the following:
If a branch is checked out (repo is not in a detached HEAD state), the push
command used is `git push <branch> <current branch>:<branch>`, pushing from the
currently checked-out branch to the named remote branch.
If no branch is checked out (repo is in detached HEAD state), the push command
used is `git push <remote> <branch>` (this is in fact unchanged from before).
Closes#15.
The commit message used by gitwatch can now be customized without having to
touch the code of the script. The new -m switch can be used for this, followed
by the commit message "template"; upon commit, all occurences of %d in that
templace string will be replaced by the formatted date/time (see also the -d
switch).
Closes#8.
Instead of having a fixed structure of PREPEND+DATE+APPEND for the commit
message, we now use a single commit message template string, in which the
placeholder %d will be replaced by the formatted date and time (if any).
This is further preparation for implementing a customizable commit message
as requested in #8.
Change the option letter for auto-pushing after a commit from -p (for 'push') to
-r (for 'remote') since I think that makes a bit more sense.
Expand the help on auto-pushing.
Add a new -d switch with which to customize the format of the timestamp inserted
into the commit message.
This prepares commit message customization as mentioned in #8.
- The bash string manipulation ${var%/*} behaves different to dirname,
e.g. paths like "/" and "/foo" return empty string
- Quote argument to dirname as preparation for using whitespace in paths
After committing the changes to the repo, the script tests if the auto-push
variables are set, to see if the push should be done. The conditions for these
if branches were exactly the wrong way around. This is now fixed.