aboutsummaryrefslogtreecommitdiffstats
path: root/add-networked-repos.sh
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-02-26 19:30:45 +0100
committerMatěj Cepl <mcepl@cepl.eu>2024-03-01 00:51:48 +0100
commit2a88ef71ca39471c14c2879d4c1b273064841707 (patch)
tree72fd97f103a24a6c44691c1a22092bf9dd75bb0a /add-networked-repos.sh
parent5c0772757d60363cd403494da365ea4cb96c22d2 (diff)
downloadhlupak-2a88ef71ca39471c14c2879d4c1b273064841707.tar.gz
fix(add-networked-repos): Rewrite the script in BASH.
Diffstat (limited to 'add-networked-repos.sh')
-rwxr-xr-xadd-networked-repos.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/add-networked-repos.sh b/add-networked-repos.sh
new file mode 100755
index 0000000..7a7df48
--- /dev/null
+++ b/add-networked-repos.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+set -eux
+set -o noglob
+
+API_URL="https://api.github.com/repos/"
+REPO_URL="https://github.com/%s/%s"
+
+if [ $# -ne 1 ] ; then
+ echo "The only parameter of the script is user/name of the repo"
+ exit 1
+fi
+
+# login=$(git config github.user)
+# passwd=$(git config github.password)
+
+get_forks() {
+ fname="${1}"
+ repo_url="$API_URL/$fname/forks"
+ repos="$(curl -s "$repo_url" | jq -r '.[]|.full_name')"
+ for full_name in $repos ; do
+ IFS='/' read -a -r names <<< "${full_name}"
+ l_user="$(echo "${names[0]}"|tr '[:upper:]' '[:lower:]')"
+ git remote add "${l_user}" "${REPO_URL}/${full_name}"
+ git fetch "${l_user}"
+ get_forks "${full_name}"
+ done
+}
+
+get_forks "${1}"