From 7a21420a25904703d0e1ed4fc3f39961c5932fe2 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 14 Feb 2023 20:14:51 +0100 Subject: First tests --- gh-clone.sh | 20 +++++++++++++++++--- 1 file 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}') -- cgit