-
Notifications
You must be signed in to change notification settings - Fork 1
/
update.sh
executable file
·79 lines (55 loc) · 1.6 KB
/
update.sh
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
update_repository(){
git fetch
git pull
}
enter_folder_and_print_inside_exit(){
# Enter folder with git
cd "$1" || exit
# Go up one level, because we are on .git
cd ..
# Check folder is git repository
if [ -d .git ]; then
base_name=$(basename "$(git rev-parse --show-toplevel)")
echo "Updating repository $base_name"
update_repository
else
folder_name=${PWD##*/}
echo "$folder_name is not a Git Repository"
fi
}
loop_folders(){
for dir in $(find ~ -name ".git" 2>&1 | grep -v "Operation not permitted")
do
enter_folder_and_print_inside_exit "$dir"
done
}
show_message(){
echo "
_ _ ___ ____ _______ ______ _____ _____ _______
| | | | __ \| __ \ /\|__ __| ____| / ____|_ _|__ __|
| | | | |__) | | | | / \ | | | |__ | | __ | | | |
| | | | ___/| | | |/ /\ \ | | | __| | | |_ | | | | |
| |__| | | | |__| / ____ \| | | |____ | |__| |_| |_ | |
\____/|_| |_____/_/ \_\_| |______| \_____|_____| |_|
by: sWallyx
"
}
clear
# Save user location
USER_PWD=$(pwd)
# Get script directory
SCRIPT_DIRECTORY="${0%/*}"
source $SCRIPT_DIRECTORY/folder-movement.sh
source $SCRIPT_DIRECTORY/auto-update.sh
show_message
echo "Thanks for using me!"
echo "Let me update the repositories for you"
move_to_script_folder
update_via_git_master
move_back_user_location
# TODO: Is this still needed?
cd ..
loop_folders
echo "All repositories updated"
echo "Have a nice coding :)"