Skip to content

Commit

Permalink
Remove oauthtokencmd config and use oauthtoken
Browse files Browse the repository at this point in the history
Instead of adding a new configuration variable, we reuse `oauthtoken` to
be able to specify a command by prefixing a !.
  • Loading branch information
llucax authored and Daniel Zullo committed Oct 30, 2020
1 parent 1bc119e commit 2eb0c58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 5 additions & 6 deletions git-hub
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,13 @@ class Config:
def __init__(self):
self.username = git_config('username', getpass.getuser())
self.oauthtoken = git_config('oauthtoken')
self.oauthtokencmd = git_config('oauthtokencmd')
if self.oauthtokencmd is not None:
if self.oauthtoken is not None and self.oauthtoken.startswith('!'):
try:
self.oauthtoken = subprocess.check_output(
self.oauthtokencmd, shell=True).strip()
cmd = self.oauthtoken[1:]
self.oauthtoken = subprocess.check_output(cmd,
shell=True).strip()
except (OSError, subprocess.CalledProcessError) as e:
die("Failed to run oauthtokencmd `{}`: {}",
self.oauthtokencmd, e)
die("Failed to run oauthtoken command `{}`: {}", cmd, e)
self.upstream = git_config('upstream')
if self.upstream and '/' not in self.upstream:
die("Invalid hub.upstream configuration, '/' not found")
Expand Down
8 changes: 5 additions & 3 deletions man.rst
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,11 @@ from. These are the git config keys used:
required, you shouldn't need to set this variable manually. Use the `setup`
command instead.

`hub.oauthtokencmd`
A command to retrieve the oauth token from a password store.
When set, `hub.oauthtoken` isn't needed.
If you don't want to store the token in plain text, you can also specify
a command by prefixing a `!`. The output of that command will be used as the
token. The command will be run with the default shell.

For example: `oauthtoken = !password-manager ~/my.db get github-oauth-token`.

`hub.upstream` required
Blessed repository used to get the issues from and make the pull requests to.
Expand Down

0 comments on commit 2eb0c58

Please sign in to comment.