mirror of https://github.com/gitwatch/gitwatch
Add current version of script to repo.
Added the current version of the shell script to the repository; file now includes the GPL license text (the short version that is usually included in source files.pull/2/head
parent
930256e1cc
commit
e15fa371c1
@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# gitwatch - watch file or directory and git commit all changes as they happen
|
||||
#
|
||||
# Copyright (C) 2012 Patrick Lehner
|
||||
#
|
||||
#############################################################################
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#############################################################################
|
||||
#
|
||||
# Idea and original code taken from http://stackoverflow.com/a/965274
|
||||
# (but heavily modified by now)
|
||||
#
|
||||
# Requires the command 'inotifywait' to be available, which is part of
|
||||
# the inotify-tools (See https://github.com/rvoicilas/inotify-tools )
|
||||
#
|
||||
|
||||
if [ -z $1 ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
IN=$(readlink -f "$1")
|
||||
|
||||
if [ -d $1 ]; then
|
||||
TARGETDIR=`echo "$IN" | sed -e "s/\/*$//" `
|
||||
INCOMMAND="inotifywait --exclude=\"^${TARGETDIR}/.git\" -qqr -e close_write,moved_to,delete $TARGETDIR"
|
||||
GITADD="."
|
||||
GITINCOMMAND=" -a"
|
||||
elif [ -f $1 ]; then
|
||||
TARGETDIR=$(dirname $IN)
|
||||
INCOMMAND="inotifywait -qq -e close_write,moved_to,delete $IN"
|
||||
GITADD="$IN"
|
||||
GITINCOMMAND=""
|
||||
else
|
||||
exit
|
||||
fi
|
||||
|
||||
#echo $INCOMMAND
|
||||
#echo $TARGETDIR
|
||||
#echo $GITPREPCOMMAND
|
||||
#echo $GITINCOMMAND
|
||||
#exit
|
||||
|
||||
while true; do
|
||||
$INCOMMAND
|
||||
sleep 2
|
||||
# echo "committing"
|
||||
DATE=`date "+%Y-%m-%d %H:%M:%S"`
|
||||
#CMD="cd $TARGETDIR ; git add $GITADD ; git commit$GITINCOMMAND -m\"Scripted auto-commit on change (${DATE})\""
|
||||
#`$CMD`
|
||||
cd $TARGETDIR
|
||||
git add $GITADD
|
||||
git commit$GITINCOMMAND -m"Scripted auto-commit on change (${DATE})"
|
||||
done
|
||||
#echo '$TARGETDIR'
|
Loading…
Reference in New Issue