aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgh-clone.sh20
1 files changed, 17 insertions, 3 deletions
diff --git a/gh-clone.sh b/gh-clone.sh
index 2a2687e..4f3fc64 100755
--- a/gh-clone.sh
+++ b/gh-clone.sh
@@ -1,12 +1,26 @@
#!/bin/bash
+set -eux
+
USERNAME=$(git config github.user)
PASSWORD=$(pass show dev/github.com|awk '/^token:/ {print $2}')
ORGANIZATION="openSUSE-Python"
+cd /home/pymirrors/repos/
+
+ORIG_REPO="$1"
+
+GH_TMP_DATA=$(mktemp /tmp/gh_data.XXXXXX.json) || exit 1
+trap 'rm -f "${GH_TMP_DATA}"' EXIT
+git clone "https://github.com/${ORIG_REPO}.git"
+cd "$(basename ${ORIG_REPO})"
-curl -s -u mcepl:$PASSWORD --json "{ \"organization\": \"$ORGANIZATION\" }" https://api.github.com/repos/JimmXinu/FanFicFare/forks |tee /tmp/curl-output.json
+curl -s -u "${USERNAME}:${PASSWORD}" \
+ --json "{ \"organization\": \"${ORGANIZATION}\" }" \
+ "https://api.github.com/repos/${ORIG_REPO}/forks" >"${GH_TMP_DATA}"
+git remote add github \
+ "$(awk -F '"' '/clone_url/ {print $4 ; exit}' "${GH_TMP_DATA}")"
+git remote set-url --push github \
+ "$(awk -F '"' '/ssh_url/ {print $4 ; exit}' "${GH_TMP_DATA}")"
git remote update
git remote -v
-git remote add github (curl -s -u mcepl:(pass show dev/github.com|awk '/^token:/ {print $2}') https://api.github.com/repos/JimmXinu/FanFicFare/forks -d ''|awk -F '"' '/clone_url/ {print $4 ; exit}')
-git remote set-url --push github (curl -s -u mcepl:(pass show dev/github.com|awk '/^token:/ {print $2}') https://api.github.com/repos/JimmXinu/FanFicFare/forks -d ''|awk -F '"' '/ssh_url/ {print $4 ; exit}')