mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
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:
parent
4a4c5296f3
commit
64993dbc7f
10
bin/git-fork
10
bin/git-fork
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue