forked from networkservicemesh/deployments-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
to-local.sh
executable file
·28 lines (23 loc) · 850 Bytes
/
to-local.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
#!/bin/bash
if [[ "$OSTYPE" == "darwin"* ]]; then
sedi() { sed -i "" "$@"; }
else
sedi() { sed -i "$@"; }
fi
escape() {
echo "$1" | sed 's/\//\\\//g'
}
get_root() {
root="$(echo "$1" | sed 's/[^/]*$//g')"
root="$(echo "$(pwd)/${root}" | sed 's/[^/]*\//..\//g')"
root="$(echo "${root}$(pwd)" | sed 's/\/\//\//g')"
escape "${root}"
}
grep 'raw.githubusercontent.com' -rl examples/* | while IFS= read -r file; do
root="$(get_root "$file")"
sedi -E "s/(https:\/\/)?raw.githubusercontent.com\/networkservicemesh\/deployments-k8s\/[a-z0-9.]*\/(.*)/${root}\/\2/g" "${file}"
done
grep 'github.com\/networkservicemesh\/deployments-k8s' -rl examples/* | while IFS= read -r file; do
root="$(get_root "$file")"
sedi -E "s/(https:\/\/)?github.com\/networkservicemesh\/deployments-k8s\/(.*)\?ref=[a-z0-9.]*/${root}\/\2/g" "${file}"
done