summaryrefslogtreecommitdiff
path: root/sync/griff
blob: 79b55de003fecbd10bee7b52752651e39a564d85 (plain)
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
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
home=$(echo $HOME | sed 's/\//\\\//g')
repos="$(grep -v '#' | sed "s/\~/$home/")" << REPOS
blr|~/.local/src/programs/blr
dmenu|~/.local/src/programs/dmenu
dotconfig|~/.config
scripts|~/.local/bin
st|~/.local/src/programs/st
timmywm|~/.local/src/programs/timmywm
REPOS
#echo "$repos" | cut -f1

# Colors
BOLD="\033[1m"
NORM="\033[0m"
CYN="\033[0;36m"
RED="\033[0;31m"
GRN="\033[0;32m"
MAG="\033[0;35m"

for repo in $repos; do
	name=$(echo $repo | cut -d'|' -f1)
	dir=$(echo $repo | cut -d'|' -f2)
	if cd $dir 2>/dev/null; then
		if git diff --quiet HEAD $REF -- $DIR; then
			echo "$GRN[Repo $name is unchanged!]$NORM"
		else
			echo "$CYN[Repo $name has changed:]$NORM"
			git status | grep -v '(use'
			read -p "Would you like to view the changes? [y/n]: " viewchange
			case $viewchange in
				y|yes|Y|Yes)
					git diff HEAD $REF -- $DIR
				;;
			esac
			read -p "Would you like to push these changes? [y/n]: " pushchange
			case $pushchange in
				y|yes|Y|Yes)
					while [ -z "$commitmsg" ]; do
						read -p "Enter a commit message: " commitmsg
					done
					git add . && git commit -m "$commitmsg" && git push \
						&& echo "$GRN[Changes to repo $name successfully pushed!]$NORM" \
						|| echo "$RED[An error occured while pushing changes to repo $name!]$NORM"
				;;
			esac
		fi
	else
		echo "$BOLD$RED[Repo $name does not exist at $dir!]$NORM"
	fi
done