From 4a4c5296f3bb3dfc17d1762c6e58f50d239a3457 Mon Sep 17 00:00:00 2001 From: Don Harper Date: Thu, 3 Jun 2021 20:19:56 -0500 Subject: [PATCH 1/6] git-fork | update to match REST-API auth standards as of 2021-06 - Removed prompt for OATH Token - Change prompt from 'password' to 'GitHub Personal Access Token' --- bin/git-fork | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/git-fork b/bin/git-fork index 7c651be44..8b8e20653 100755 --- a/bin/git-fork +++ b/bin/git-fork @@ -14,10 +14,8 @@ 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 password for user \"$user\"" +echo "Enter github Personal Access Token for user \"$user\"" read -s passwd -echo "Enter github two-factor authentication code (leave blank if not set up)" -read MFA_CODE # extract owner + project from repo url project=${url##*/} From 64993dbc7fdbfc797d05bd62e129b933d8bb1fe9 Mon Sep 17 00:00:00 2001 From: Don Harper Date: Fri, 4 Jun 2021 20:08:07 -0500 Subject: [PATCH 2/6] bin/git-fork | updating for feedback from PR #928 Added support for pulling personal-access-token, borrowing from git-pull-request --- bin/git-fork | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/git-fork b/bin/git-fork index 8b8e20653..0fd999498 100755 --- a/bin/git-fork +++ b/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" From d8b1007f688819857a158dfe650c8865e5ee97e5 Mon Sep 17 00:00:00 2001 From: Don Harper Date: Fri, 4 Jun 2021 20:12:41 -0500 Subject: [PATCH 3/6] Updated documentation (AUTHORS) --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index a449ad56e..64a1091d5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -237,3 +237,4 @@ Patches and Suggestions - Étienne BERSAC - ☃ pitr - 单元源 +- Don 'duckunix' Harper From b8b02d8ef1fa46b888bd308e6da2929a389d435b Mon Sep 17 00:00:00 2001 From: Don Harper Date: Fri, 4 Jun 2021 23:04:31 -0500 Subject: [PATCH 4/6] git-fork | Update man/md/html pages to talk about need of the github personal access token --- man/git-fork.1 | 14 ++++++++++++++ man/git-fork.html | 10 ++++++++++ man/git-fork.md | 10 ++++++++++ 3 files changed, 34 insertions(+) diff --git a/man/git-fork.1 b/man/git-fork.1 index 777a38ce1..e605bc525 100644 --- a/man/git-fork.1 +++ b/man/git-fork.1 @@ -40,6 +40,20 @@ adds the forked repo as a remote called \fBorigin\fR .P Remotes will use ssh if you have it configured with GitHub, if not, https will be used\. . +Create pull request for a project on GitHub via command line\. +. +.P +A personal access token is required for making the API call to open the pull request(s) in GitHub\. API Documentation here \fIhttps://docs\.github\.com/en/rest/reference/pulls#create\-a\-pull\-request\fR +. +.P +Make sure the personal access token has the right \fBOAuth\fR scopes for the repo(s) +. +.P +Use \fBgit config \-\-global \-\-add git\-extras\.github\-personal\-access\-token \fR +. +.P +If using multiple accounts, override the global value in the specific repo using \fBgit config git\-extras\.github\-personal\-access\-token \fR +. .SH "EXAMPLE" Fork expect\.js: . diff --git a/man/git-fork.html b/man/git-fork.html index 9c68ce30d..3883b7384 100644 --- a/man/git-fork.html +++ b/man/git-fork.html @@ -99,6 +99,16 @@

DESCRIPTION

Remotes will use ssh if you have it configured with GitHub, if not, https will be used.

+

Create pull request for a project on GitHub via command line.

+ +

A personal access token is required for making the API call to open the pull request(s) in GitHub. API Documentation here

+ +

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

+ +

Use git config --global --add git-extras.github-personal-access-token <your-personal-access-token>

+ +

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>

+

EXAMPLE

Fork expect.js:

diff --git a/man/git-fork.md b/man/git-fork.md index 890c5d963..fecbe7e7a 100644 --- a/man/git-fork.md +++ b/man/git-fork.md @@ -21,6 +21,16 @@ git-fork(1) -- Fork a repo on github Remotes will use ssh if you have it configured with GitHub, if not, https will be used. + Create pull request for a project on GitHub via command line. + + A personal access token is required for making the API call to open the pull request(s) in GitHub. [API Documentation here](https://docs.github.com/en/rest/reference/pulls#create-a-pull-request) + + Make sure the personal access token has the right `OAuth` scopes for the repo(s) + + Use `git config --global --add git-extras.github-personal-access-token ` + + If using multiple accounts, override the global value in the specific repo using `git config git-extras.github-personal-access-token ` + ## EXAMPLE Fork expect.js: From 1f72512ef0c0f18e2478d5a3395e664359f69f3d Mon Sep 17 00:00:00 2001 From: Don Harper Date: Sun, 6 Jun 2021 21:26:01 -0500 Subject: [PATCH 5/6] update working --- man/git-fork.1 | 4 ++-- man/git-fork.html | 4 ++-- man/git-fork.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/man/git-fork.1 b/man/git-fork.1 index e605bc525..7a5e42c8e 100644 --- a/man/git-fork.1 +++ b/man/git-fork.1 @@ -40,10 +40,10 @@ adds the forked repo as a remote called \fBorigin\fR .P Remotes will use ssh if you have it configured with GitHub, if not, https will be used\. . -Create pull request for a project on GitHub via command line\. +Create a fork a project on GitHub via command line\. . .P -A personal access token is required for making the API call to open the pull request(s) in GitHub\. API Documentation here \fIhttps://docs\.github\.com/en/rest/reference/pulls#create\-a\-pull\-request\fR +A personal access token is required for making the API call to create a new fork in GitHub\. API Documentation here \fIhttps://docs\.github\.com/en/rest/reference/pulls#create\-a\-pull\-request\fR . .P Make sure the personal access token has the right \fBOAuth\fR scopes for the repo(s) diff --git a/man/git-fork.html b/man/git-fork.html index 3883b7384..238ec1da3 100644 --- a/man/git-fork.html +++ b/man/git-fork.html @@ -99,9 +99,9 @@

DESCRIPTION

Remotes will use ssh if you have it configured with GitHub, if not, https will be used.

-

Create pull request for a project on GitHub via command line.

+

Create a fork of a project on GitHub via command line.

-

A personal access token is required for making the API call to open the pull request(s) in GitHub. API Documentation here

+

A personal access token is required for making the API call to create a new fork in GitHub. API Documentation here

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

diff --git a/man/git-fork.md b/man/git-fork.md index fecbe7e7a..916956243 100644 --- a/man/git-fork.md +++ b/man/git-fork.md @@ -21,9 +21,9 @@ git-fork(1) -- Fork a repo on github Remotes will use ssh if you have it configured with GitHub, if not, https will be used. - Create pull request for a project on GitHub via command line. + Create a fork of a project on GitHub via command line. - A personal access token is required for making the API call to open the pull request(s) in GitHub. [API Documentation here](https://docs.github.com/en/rest/reference/pulls#create-a-pull-request) + A personal access token is required for making the API call to create a fork in GitHub. [API Documentation here](https://docs.github.com/en/rest/reference/pulls#create-a-pull-request) Make sure the personal access token has the right `OAuth` scopes for the repo(s) From 30383f955115794361df9d93fda3a48b1cacf1e3 Mon Sep 17 00:00:00 2001 From: Don Harper Date: Mon, 7 Jun 2021 20:12:22 -0500 Subject: [PATCH 6/6] Update point to github docs for forks from API --- man/git-fork.1 | 2 +- man/git-fork.html | 2 +- man/git-fork.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/man/git-fork.1 b/man/git-fork.1 index 7a5e42c8e..e259745e7 100644 --- a/man/git-fork.1 +++ b/man/git-fork.1 @@ -43,7 +43,7 @@ Remotes will use ssh if you have it configured with GitHub, if not, https will b Create a fork a project on GitHub via command line\. . .P -A personal access token is required for making the API call to create a new fork in GitHub\. API Documentation here \fIhttps://docs\.github\.com/en/rest/reference/pulls#create\-a\-pull\-request\fR +A personal access token is required for making the API call to create a new fork in GitHub\. API Documentation here \fIhttps://docs\.github\.com/en/rest/reference/repos#forks\fR . .P Make sure the personal access token has the right \fBOAuth\fR scopes for the repo(s) diff --git a/man/git-fork.html b/man/git-fork.html index 238ec1da3..3ad0fbf5a 100644 --- a/man/git-fork.html +++ b/man/git-fork.html @@ -101,7 +101,7 @@

DESCRIPTION

Create a fork of a project on GitHub via command line.

-

A personal access token is required for making the API call to create a new fork in GitHub. API Documentation here

+

A personal access token is required for making the API call to create a new fork in GitHub. API Documentation here

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

diff --git a/man/git-fork.md b/man/git-fork.md index 916956243..701ac87a9 100644 --- a/man/git-fork.md +++ b/man/git-fork.md @@ -23,7 +23,7 @@ git-fork(1) -- Fork a repo on github Create a fork of a project on GitHub via command line. - A personal access token is required for making the API call to create a fork in GitHub. [API Documentation here](https://docs.github.com/en/rest/reference/pulls#create-a-pull-request) + A personal access token is required for making the API call to create a fork in GitHub. [API Documentation here](https://docs.github.com/en/rest/reference/repos#forks) Make sure the personal access token has the right `OAuth` scopes for the repo(s)