Skip to content

Commit b7d5c96

Browse files
duckunixspacewander
authored andcommitted
bin/git-fork | updating for feedback from PR tj#928
Added support for pulling personal-access-token, borrowing from git-pull-request
1 parent 25daa7c commit b7d5c96

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

bin/git-fork

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ test -z "$url" && abort "github repo needs to be specified as an argument"
1414
echo "Enter your github username"
1515
read user
1616
[ -n "$user" ] || abort "git username required"
17-
echo "Enter github Personal Access Token for user \"$user\""
18-
read -s passwd
17+
# personal access token
18+
# config name is github-personal-access-token '_' is not allowed in git config
19+
20+
github_personal_access_token=$(git config git-extras.github-personal-access-token)
21+
22+
test -z "$github_personal_access_token" && abort "git config git-extras.github-personal-access-token required"
1923

2024
# extract owner + project from repo url
2125
project=${url##*/}
@@ -33,7 +37,7 @@ fi
3337
# create fork
3438
curl -qsf \
3539
-X POST \
36-
-u "$user:$passwd" \
40+
-u "$user:$github_personal_access_token" \
3741
-H "X-GitHub-OTP: $MFA_CODE" \
3842
"https://api.github.com/repos/$owner/$project/forks"
3943

0 commit comments

Comments
 (0)