aboutsummaryrefslogtreecommitdiffstats
path: root/gh-clone.sh
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2023-02-14 20:14:51 +0100
committerMatěj Cepl <mcepl@cepl.eu>2024-07-19 10:31:48 +0200
commit7a21420a25904703d0e1ed4fc3f39961c5932fe2 (patch)
tree482b0d2548d9d247205dd393385459f0e72e1543 /gh-clone.sh
parent484d7e5251d25f50c1187365b9603be6be6054bb (diff)
downloadhlupak-7a21420a25904703d0e1ed4fc3f39961c5932fe2.tar.gz
First tests
Diffstat (limited to 'gh-clone.sh')
-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}')