From 2eb0c58e0ca612cd4ec7ec8f29f6b2a3a55d6cb4 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Fri, 30 Oct 2020 11:38:41 +0100 Subject: [PATCH] Remove oauthtokencmd config and use oauthtoken Instead of adding a new configuration variable, we reuse `oauthtoken` to be able to specify a command by prefixing a !. --- git-hub | 11 +++++------ man.rst | 8 +++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/git-hub b/git-hub index afffae2..69b18e1 100755 --- a/git-hub +++ b/git-hub @@ -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") diff --git a/man.rst b/man.rst index 9f7254f..80ce2c0 100644 --- a/man.rst +++ b/man.rst @@ -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.