bin/git-fork | updating for feedback from PR #928

Added support for pulling personal-access-token, borrowing from git-pull-request
This commit is contained in:
Don Harper 2021-06-04 20:08:07 -05:00
parent 4a4c5296f3
commit 64993dbc7f

View file

@ -14,8 +14,12 @@ test -z "$url" && abort "github repo needs to be specified as an argument"
echo "Enter your github username"
read user
[ -n "$user" ] || abort "git username required"
echo "Enter github Personal Access Token for user \"$user\""
read -s passwd
# personal access token
# config name is github-personal-access-token '_' is not allowed in git config
github_personal_access_token=$(git config git-extras.github-personal-access-token)
test -z "$github_personal_access_token" && abort "git config git-extras.github-personal-access-token required"
# extract owner + project from repo url
project=${url##*/}
@ -33,7 +37,7 @@ fi
# create fork
curl -qsf \
-X POST \
-u "$user:$passwd" \
-u "$user:$github_personal_access_token" \
-H "X-GitHub-OTP: $MFA_CODE" \
"https://api.github.com/repos/$owner/$project/forks"