Skip to content

Commit d291b27

Browse files
nim65sspacewander
andauthored
Support GITHUB_TOKEN var for git-fork and git-pull-request (#1177)
Co-authored-by: 罗泽轩 <[email protected]>
1 parent fb0bc69 commit d291b27

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

bin/git-fork

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ read -r user
1717
# personal access token
1818
# config name is github-personal-access-token '_' is not allowed in git config
1919

20-
github_personal_access_token=$(git config git-extras.github-personal-access-token)
20+
github_personal_access_token=$(git config --default "$GITHUB_TOKEN" git-extras.github-personal-access-token)
2121

22-
test -z "$github_personal_access_token" && abort "git config git-extras.github-personal-access-token required"
22+
test -z "$github_personal_access_token" && abort "GITHUB_TOKEN, or git config git-extras.github-personal-access-token required"
2323

2424
# extract owner + project from repo url
2525
project=${url##*/}

bin/git-pull-request

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ EOF
3131
# personal access token
3232
# config name is github-personal-access-token '_' is not allowed in git config
3333

34-
github_personal_access_token=$(git config git-extras.github-personal-access-token)
34+
github_personal_access_token=$(git config --default "$GITHUB_TOKEN" git-extras.github-personal-access-token)
3535

36-
test -z "$github_personal_access_token" && abort "git config git-extras.github-personal-access-token required"
36+
test -z "$github_personal_access_token" && abort "GITHUB_TOKEN or git config git-extras.github-personal-access-token required"
3737

3838
# branch
3939

man/git-fork.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ A personal access token is required for making the API call to create a new fork
4949
Make sure the personal access token has the right \fBOAuth\fR scopes for the repo(s)
5050
.
5151
.P
52-
Use \fBgit config \-\-global \-\-add git\-extras\.github\-personal\-access\-token <your\-personal\-access\-token>\fR
52+
Use \fBGITHUB_TOKEN\fR environment variable, or \fBgit config \-\-global \-\-add git\-extras\.github\-personal\-access\-token <your\-personal\-access\-token>\fR
5353
.
5454
.P
5555
If using multiple accounts, override the global value in the specific repo using \fBgit config git\-extras\.github\-personal\-access\-token <other\-acc\-personal\-access\-token>\fR

man/git-fork.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/git-fork.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ git-fork(1) -- Fork a repo on github
2727

2828
Make sure the personal access token has the right `OAuth` scopes for the repo(s)
2929

30-
Use `git config --global --add git-extras.github-personal-access-token <your-personal-access-token>`
30+
Use `GITHUB_TOKEN` environment variable, or `git config --global --add git-extras.github-personal-access-token <your-personal-access-token>`
3131

3232
If using multiple accounts, override the global value in the specific repo using `git config git-extras.github-personal-access-token <other-acc-personal-access-token>`
3333

man/git-pull-request.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ A personal access token is required for making the API call to open the pull req
1919
Make sure the personal access token has the right \fBOAuth\fR scopes for the repo(s)
2020
.
2121
.P
22-
Use \fBgit config \-\-global \-\-add git\-extras\.github\-personal\-access\-token <your\-personal\-access\-token>\fR
22+
Use \fBGITHUB_TOKEN\fR environment variable, or \fBgit config \-\-global \-\-add git\-extras\.github\-personal\-access\-token <your\-personal\-access\-token>\fR
2323
.
2424
.P
2525
If using multiple accounts, override the global value in the specific repo using \fBgit config git\-extras\.github\-personal\-access\-token <other\-acc\-personal\-access\-token>\fR

man/git-pull-request.html

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/git-pull-request.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A personal access token is required for making the API call to open the pull req
1313

1414
Make sure the personal access token has the right `OAuth` scopes for the repo(s)
1515

16-
Use `git config --global --add git-extras.github-personal-access-token <your-personal-access-token>`
16+
Use `GITHUB_TOKEN` environment variable, or `git config --global --add git-extras.github-personal-access-token <your-personal-access-token>`
1717

1818
If using multiple accounts, override the global value in the specific repo using `git config git-extras.github-personal-access-token <other-acc-personal-access-token>`
1919

0 commit comments

Comments
 (0)