all repos — shwarp-tools @ 189be834b970629fa4e24a1de2f57d95e6e6674f

Tools and scripts

tools/autocommit (view raw, download)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
#!/bin/bash

if [[ $# -ne 2 ]]
then
    echo "Usage: ./autocommit <DIR> <FILE> [COMMIT_MESSAGE]"
    exit 1
fi

DIRECTORY="$1"
FILE="$2"
COMMIT_MESSAGE="auto: $FILE changed"

while true
do
    cd "$DIRECTORY"

    inotifywait -qq -e CLOSE_WRITE "$FILE"

    echo "File changed: $DIRECTORY/$FILE"

    # Keep duplicate updates out
    sleep 1s

    git add "$FILE"
    git commit -m "$COMMIT_MESSAGE"

    git log --oneline --reverse
done