summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeah (ctucx) <leah@ctu.cx>2021-03-01 17:32:28 +0100
committerLeah (ctucx) <leah@ctu.cx>2021-03-01 17:32:28 +0100
commit0370a4e20335b4c8feafed7728658bc6d8f4ce01 (patch)
tree8688ac5cd42d3e32141478b07b1fbe156abf04fe
parentba57f51d0fefc9888cbb843b110c6df23c206093 (diff)
downloaddotfiles-0370a4e20335b4c8feafed7728658bc6d8f4ce01.tar.gz
dotfiles-0370a4e20335b4c8feafed7728658bc6d8f4ce01.tar.bz2
dotfiles-0370a4e20335b4c8feafed7728658bc6d8f4ce01.zip
add proj update script
-rw-r--r--proj/.keep0
-rw-r--r--proj/executable_update.sh39
2 files changed, 39 insertions, 0 deletions
diff --git a/proj/.keep b/proj/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/proj/.keep
diff --git a/proj/executable_update.sh b/proj/executable_update.sh
new file mode 100644
index 0000000..c64187b
--- /dev/null
+++ b/proj/executable_update.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+update () {
+ if [ -d "$HOME/proj/$1" ]; then
+ if [ -z "$(git -C $HOME/proj/$1 status --porcelain=v1 2>/dev/null)" ]; then
+ echo "Pull changes for: ~/.proj/$1"
+ git -C $HOME/proj/$1 pull --no-rebase origin master
+ else
+ GS=$(git -C $HOME/proj/$1 status --porcelain=v1 2>/dev/null) # Exit code 128 if not in git directory. Unfortunately this exit code is a bit generic but it should work for most purposes.
+ if [ $? -ne 128 ]; then
+ function _count_git_pattern() {
+ echo "$(grep "^$1" <<< $GS | wc -l)"
+ }
+
+ echo "Not pulling remote changes for ~/proj/$1 because:"
+ echo "There are $(_count_git_pattern "??") untracked files."
+ echo "There are $(_count_git_pattern " M") unstaged, modified files."
+ echo "There are $(_count_git_pattern "M ") staged, modified files."
+ fi
+ fi
+ else
+ echo "Clone $1 into directory ~/proj/$1"
+ git clone ctucx-cgit:$1 $HOME/proj/$1
+ fi
+}
+
+update "gitolite-admin"
+update "alpine-pkgs"
+update "ansible-configs"
+update "dns-zones"
+update "ctucxbot"
+update "dnsmasq-leases-overview"
+update "gallery"
+update "hafas.nim"
+update "oeffi-web"
+update "oeffisearch"
+update "serial2tcp"
+update "smartie-pwa"
+update "smartied" \ No newline at end of file