summaryrefslogtreecommitdiffstats
path: root/proj/executable_update.sh
blob: b065b0728b5e2476f4c2ccc4c3a075e97f43570d (plain) (blame)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/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-lease-overview"
update "gallery"
update "nimhafas"
update "nimexif"
update "nimjpg"
update "oeffi-web"
update "oeffisearch"
update "serial2tcp"
update "smartie-pwa"
update "smartied"