-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-refresh
More file actions
executable file
·70 lines (50 loc) · 1.4 KB
/
git-refresh
File metadata and controls
executable file
·70 lines (50 loc) · 1.4 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
64
65
66
67
68
69
70
#!/usr/bin/env bash
source "utils.sh"
branch=${1}
if [[ "${branch}" != "" ]]; then
write "Updating <magenta>${branch}</magenta>... "
git fetch -q origin "${branch}:${branch}" > /dev/null 2>&1
s="${?}"
if [[ $s != 128 ]]; then
writeln "<green>done</green>"
else
writeln "<red>branch not found</red>"
fi
exit 0
fi
# Check if params are enough to go ahead.
branch=$(git symbolic-ref --short -q HEAD)
git fetch -q
if [[ "${branch}" != "main" ]]; then
write "Updating <magenta>main</magenta>... "
git fetch -q origin main:main > /dev/null 2>&1
s="${?}"
if [[ $s != 128 ]]; then
writeln "<green>done</green>"
else
writeln "<red>branch not found</red>"
fi
fi
if [[ "${branch}" != "master" ]]; then
write "Updating <magenta>master</magenta>... "
git fetch -q origin master:master > /dev/null 2>&1
s="${?}"
if [[ $s != 128 ]]; then
writeln "<green>done</green>"
else
writeln "<red>branch not found</red>"
fi
fi
if [[ "${branch}" != "develop" ]]; then
write "Updating <magenta>develop</magenta>... "
git fetch -q origin develop:develop > /dev/null 2>&1
s="${?}"
if [[ $s != 128 ]]; then
writeln "<green>done</green>"
else
writeln "<red>branch not found</red>"
fi
fi
write "Updating <magenta>${branch}</magenta>... "
git pull --quiet
writeln "<green>done</green>"