diff options
| author | Paul Buetow <git@mx.buetow.org> | 2021-05-25 22:10:09 +0100 |
|---|---|---|
| committer | Paul Buetow <git@mx.buetow.org> | 2021-05-25 22:10:09 +0100 |
| commit | 2a3fa5b8c749e631d2d7ed1bb01300f023c4b9ea (patch) | |
| tree | 46761b18297bc50e70fb61bef6031b33d5e31db5 /lib/git.source.sh | |
| parent | b7489882bc82e4266e9cb9845604acdf20857c23 (diff) | |
rename packages to lib1.0.0
Diffstat (limited to 'lib/git.source.sh')
| -rw-r--r-- | lib/git.source.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/git.source.sh b/lib/git.source.sh new file mode 100644 index 0000000..c502b00 --- /dev/null +++ b/lib/git.source.sh @@ -0,0 +1,50 @@ +# Add a static content file to git +git::add () { + if [[ "$USE_GIT" != yes ]]; then + return + fi + + local -r content_dir="$CONTENT_BASE_DIR/$1"; shift + local file="$1"; shift + file=${file/$content_dir/.\/} + + cd "$content_dir" &>/dev/null + git add "$file" + cd - &>/dev/null +} + +# Remove a static content file from git +git::rm () { + if [[ "$USE_GIT" != yes ]]; then + return + fi + + local -r content_dir="$CONTENT_BASE_DIR/$1"; shift + local file="$1"; shift + file=${file/$content_dir/.\/} + + cd "$content_dir" &>/dev/null + git rm "$file" + cd - &>/dev/null +} + +# Commit all changes +git::commit () { + if [[ "$USE_GIT" != yes ]]; then + return + fi + + local -r content_dir="$CONTENT_BASE_DIR/$1"; shift + local -r message="$1"; shift + + cd "$content_dir" &>/dev/null + set +e + git commit -a -m "$message" + if [[ "$GIT_PUSH" == yes ]]; then + log INFO "Invoking git pull/push in $content_dir" + git pull + git push + fi + set -e + cd - &>/dev/null +} |
