From afd9fdf7ca0800c457959b540c4378d20f802dc0 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 19 May 2021 19:46:20 +0100 Subject: add git package --- packages/git.source.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 packages/git.source.sh (limited to 'packages/git.source.sh') diff --git a/packages/git.source.sh b/packages/git.source.sh new file mode 100644 index 0000000..1484e93 --- /dev/null +++ b/packages/git.source.sh @@ -0,0 +1,31 @@ +# Add a static content file to git +git::add () { + local -r content_dir="$CONTENT_BASE_DIR/$1"; shift + local file="$1"; shift + file=${file/$content_dir/} + + cd $content_dir + echo git add $file + cd - +} + +# Remove a static content file from git +git::rm () { + local -r content_dir="$CONTENT_BASE_DIR/$1"; shift + local file="$1"; shift + file=${file/$content_dir/} + + cd $content_dir + echo git rm $file + cd - +} + +# Commit all changes +git::commit () { + local -r content_dir="$CONTENT_BASE_DIR/$1"; shift + local -r message="$1"; shift + + cd $content_dir + echo git commit -a -m "$message" + cd - +} -- cgit v1.2.3 From 14822623456972b0dbe9dc5b6c36b701bb6ec7f1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 19 May 2021 20:01:47 +0100 Subject: Removal of Makefile and some fixes/refactorings --- packages/git.source.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'packages/git.source.sh') diff --git a/packages/git.source.sh b/packages/git.source.sh index 1484e93..ec8e853 100644 --- a/packages/git.source.sh +++ b/packages/git.source.sh @@ -2,22 +2,22 @@ git::add () { local -r content_dir="$CONTENT_BASE_DIR/$1"; shift local file="$1"; shift - file=${file/$content_dir/} + file=${file/$content_dir/.\/} - cd $content_dir - echo git add $file - cd - + cd "$content_dir" &>/dev/null + git add "$file" + cd - &>/dev/null } # Remove a static content file from git git::rm () { local -r content_dir="$CONTENT_BASE_DIR/$1"; shift local file="$1"; shift - file=${file/$content_dir/} + file=${file/$content_dir/.\/} - cd $content_dir - echo git rm $file - cd - + cd "$content_dir" &>/dev/null + git rm "$file" + cd - &>/dev/null } # Commit all changes @@ -25,7 +25,7 @@ git::commit () { local -r content_dir="$CONTENT_BASE_DIR/$1"; shift local -r message="$1"; shift - cd $content_dir - echo git commit -a -m "$message" - cd - + cd "$content_dir" &>/dev/null + git commit -a -m "$message" + cd - &>/dev/null } -- cgit v1.2.3 From d354a3ffb999c27ece66f8a66dfb416e5d5d7b6c Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 19 May 2021 20:19:52 +0100 Subject: add GIT_PUSH --- packages/git.source.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'packages/git.source.sh') diff --git a/packages/git.source.sh b/packages/git.source.sh index ec8e853..9ee238c 100644 --- a/packages/git.source.sh +++ b/packages/git.source.sh @@ -20,6 +20,20 @@ git::rm () { cd - &>/dev/null } +# Commit all changes +git::commit () { + local -r content_dir="$CONTENT_BASE_DIR/$1"; shift + local -r message="$1"; shift + + cd "$content_dir" &>/dev/null + git commit -a -m "$message" + if [[ "$GIT_PUSH" == yes ]]; then + git pull + git push + fi + cd - &>/dev/null +} + # Commit all changes git::commit () { local -r content_dir="$CONTENT_BASE_DIR/$1"; shift -- cgit v1.2.3 From 61aeed196b412ca0c57a8b7a52593215752f1e37 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 20 May 2021 08:40:59 +0100 Subject: some log bugfixing, also add another alternate config file path --- packages/git.source.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'packages/git.source.sh') diff --git a/packages/git.source.sh b/packages/git.source.sh index 9ee238c..ca1f475 100644 --- a/packages/git.source.sh +++ b/packages/git.source.sh @@ -26,20 +26,13 @@ git::commit () { 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 - cd - &>/dev/null -} - -# Commit all changes -git::commit () { - local -r content_dir="$CONTENT_BASE_DIR/$1"; shift - local -r message="$1"; shift - - cd "$content_dir" &>/dev/null - git commit -a -m "$message" + set -e cd - &>/dev/null } -- cgit v1.2.3 From 65f8a2497bad58619d0cfdc76e4a0efeb15e0306 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 20 May 2021 17:51:07 +0100 Subject: initial macos support --- packages/git.source.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'packages/git.source.sh') diff --git a/packages/git.source.sh b/packages/git.source.sh index ca1f475..c502b00 100644 --- a/packages/git.source.sh +++ b/packages/git.source.sh @@ -1,5 +1,9 @@ # 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/.\/} @@ -11,6 +15,10 @@ git::add () { # 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/.\/} @@ -22,6 +30,10 @@ git::rm () { # 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 -- cgit v1.2.3