-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvercel-submodule-workaround.sh
More file actions
47 lines (37 loc) · 1.19 KB
/
vercel-submodule-workaround.sh
File metadata and controls
47 lines (37 loc) · 1.19 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
#!/usr/bin/env bash
set -xEeuo pipefail
GITMODULES=".gitmodules"
FEXT=".bak"
GITMODULES_BACKUP="${GITMODULES}${FEXT}"
function cleanup {
echo "Cleaning the runner..."
rm -f "$GITMODULES" "$GITMODULES_BACKUP"
git restore "$GITMODULES"
echo "Done!"
}
trap cleanup EXIT
function submodule_workaround {
if [ -z "${GITHUB_TOKEN:-}" ]; then
echo "GITHUB_TOKEN is empty!"
exit 1
fi
echo "Monkey patching..."
sed -i"$FEXT" "s|url = \.\./|url = https://oauth2:${GITHUB_TOKEN}@github.com/cursor-js/|" "$GITMODULES"
sed -i"$FEXT" "s|url = https://github.com/|url = https://oauth2:${GITHUB_TOKEN}@github.com/|" "$GITMODULES"
echo "Done!"
echo "Synchronising submodules' remote URL configuration..."
git submodule sync
echo "Done!"
echo "Cleaning cached submodule directories..."
git config --file .gitmodules --get-regexp path | awk '{print $2}' | while read -r dir; do
if [ -d "$dir" ]; then
echo " Removing $dir"
rm -rf "$dir"
fi
done
echo "Done!"
echo "Updating the registered submodules to match what the superproject expects..."
git submodule update --init --force --recursive --jobs "$(getconf _NPROCESSORS_ONLN)"
echo "Done!"
}
submodule_workaround