Repository navigation
Expand file tree
/
Copy pathgits
More file actions
63 lines (50 loc) · 1.69 KB
/
Copy pathgits
File metadata and controls
63 lines (50 loc) · 1.69 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
bold=$(tput bold)
normal=$(tput sgr0)
COLOR_GRAY="\033[1;38;5;243m"
COLOR_BLUE="\033[1;34m"
COLOR_GREEN="\033[1;32m"
COLOR_RED="\033[1;31m"
COLOR_PURPLE="\033[1;35m"
COLOR_YELLOW="\033[1;33m"
COLOR_NONE="\033[0m"
COLOR_GRAY="\033[1;38;5;243m"
repos=""
if [ -d "$HOME"/Code/Github ]; then
repos="$HOME/Code/Github/"
else
mkdir -p "$HOME"/Code/Github
repos="$HOME/Code/Github/"
fi
title() {
echo -e "\n${COLOR_PURPLE}$1${COLOR_NONE}"
echo -e "${COLOR_GRAY}==============================${COLOR_NONE}\n"
}
success=0
warning=0
fail=0
echo ""
for repo in "$repos"*; do
repo_name=$(basename "$repo")
if [ "$(git -C "$repo" status 2> /dev/null | grep -i "nothing to commit")" ]; then
printf "${COLOR_GREEN}Fetching${COLOR_NONE} %s \n" "$repo_name"
if git -C "$repo" fetch 2> /dev/null; then
printf "${COLOR_GREEN}Pulling${COLOR_NONE} %s" "$repo_name"
#exa --long --tree --level=1 "$repo"
git &> /dev/null -C "$repo" pull --rebase; echo -e "${COLOR_GREEN} [Ok]"
sleep 1
success=$((success+1))
else
printf "${COLOR_RED}Error:${COLOR_NONE} Couldn't fetch %s\n" "$repo_name"
fail=$((fail+1))
continue
fi
else
printf "${COLOR_YELLOW}Warning:${COLOR_NONE} ${bold}%s${normal} has uncommitted changes.\n" "$repo_name"
warning=$((warning+1))
fi
done
repo_count=$(ls -l "$repos" | grep -v '^d' | wc -l)
printf "\nSummary: ${COLOR_BLUE}Repos${COLOR_NONE} %d | ${COLOR_BLUE}Updates${COLOR_NONE} %d | ${COLOR_BLUE}Failures${COLOR_NONE} %d | ${COLOR_BLUE}warnings${COLOR_NONE} %d \n" "$repo_count" "$success" "$fail" "$warning"
echo ""
exit