blob: 4f3fc648330a7287e9995f69254264db0c8faa15 (
plain) (
blame)
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
|
#!/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 "${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
|