2021-10-31 20:21:35 +01:00
|
|
|
#!/bin/sh -e
|
2021-06-19 21:24:14 +02:00
|
|
|
# Clones a fork and sets a corresponding upstream
|
2021-10-11 10:02:14 +02:00
|
|
|
# ARGS
|
2022-01-11 13:23:56 +01:00
|
|
|
# - repo name (omit if setting upstream in existing repo)
|
2021-06-19 21:24:14 +02:00
|
|
|
# - upstream user
|
|
|
|
# - local user
|
2021-10-11 10:02:14 +02:00
|
|
|
# - url
|
2021-10-08 12:31:00 +02:00
|
|
|
# - target directory name (and further arguments to clone)
|
2021-10-31 20:21:35 +01:00
|
|
|
if test -d ".git"
|
2022-01-11 13:23:56 +01:00
|
|
|
then repo="$(basename "$PWD")"
|
|
|
|
git remote set-url origin "$(git-repo "${3:-github.com}" "$repo" "$2" "${@:4}")"
|
2022-01-12 12:44:28 +01:00
|
|
|
else repo="$1" && shift
|
|
|
|
git-get "${3:-github.com}" "$repo" "${2:-$(git config --get user.name)}" "${@:4}"
|
|
|
|
cd "$(expr "$4" \| "$repo")"
|
2021-10-31 20:21:35 +01:00
|
|
|
fi
|
2022-01-12 12:44:28 +01:00
|
|
|
test -n "$1" && git remote add upstream "$(git-repo "${3:-github.com}" "$repo" "$1")"
|
2021-06-19 21:24:14 +02:00
|
|
|
git remote -v
|