-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrcs.sh
More file actions
executable file
·76 lines (66 loc) · 2.12 KB
/
Copy pathsrcs.sh
File metadata and controls
executable file
·76 lines (66 loc) · 2.12 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
71
72
73
74
75
76
# add all git sources of the repository to the local git config file
set -e
FILE=$(cat ./.git/config)
FILE=$(
REMOTE=; url=; urls=;
printf "%s" "$FILE" | { while IFS= read -r LINE || [ "$LINE" ]; do
case "$LINE" in
'[remote "origin"]')
REMOTE="$REMOTE$LINE
"
remote_flag=1
;;
'['*)
[ "$REMOTE" ] || { printf "%s\n" "$LINE"; continue; }
REMOTE=$(printf "%s" "$REMOTE" | { while IFS= read -r _line; do
if [ ! "$url" ]; then
case "$_line" in
*'url = '*) url="$_line" ;;
*) printf "%s\n" "$_line" ;;
esac
continue
fi
case "$_line" in
*'url = '*)
urls="$urls${_line%.git}.git
"
continue
;;
esac
printf "%s\n" "$url"
for _url in \
'https://github.com/mscalindt/scripts' \
'https://gitlab.com/mscalindt/scripts' \
'https://codeberg.org/mscalindt/scripts'; do
case "${url%.git}.git
$urls" in
*"url = ${_url%.git}.git
"*)
;;
*)
urls="$urls url = ${_url%.git}.git
"
;;
esac
done
printf "%s" "$urls"
printf "%s\n" "$_line"
url=; urls=
done; }; )
printf "%s\n" "$REMOTE"
printf "%s\n" "$LINE"
REMOTE=
remote_flag=
;;
*)
if [ "$remote_flag" ]; then
REMOTE="$REMOTE$LINE
"
else
printf "%s\n" "$LINE"
fi
;;
esac
done; }
)
printf "%s\n" "$FILE" > ./.git/config