File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,23 @@ def simple_fallback(message=None):
3636 k , v = line .split (': ' , 1 )
3737 kvs [k ] = v
3838
39- if not kvs .get ('user.login' ):
39+ login = kvs .get ('user.login' )
40+ if not login :
4041 return simple_fallback ('.githubrc missing user.login. Using anonymous API access.' )
41- if not kvs .get ('user.password' ):
42- return simple_fallback ('.githubrc missing user.password. Using anonymous API access.' )
43- return Github (kvs ['user.login' ], kvs ['user.password' ])
42+
43+ password = kvs .get ('user.password' )
44+ token = kvs .get ('user.token' )
45+
46+ if password and token :
47+ raise OnlyPasswordOrToken ('Only specify user.token or user.password '
48+ 'in your .githubrc file (got both)' )
49+
50+ auth = token or password
51+
52+ if not auth :
53+ return simple_fallback ('.githubrc has neither user.password nor user.token.'
54+ 'Using anonymous API access.' )
55+ return Github (login , auth )
4456 else :
4557 return Github ()
4658
@@ -51,6 +63,9 @@ class NoRemoteError(Exception):
5163class UnknownPullRequestError (Exception ):
5264 pass
5365
66+ class OnlyPasswordOrToken (Exception ):
67+ pass
68+
5469
5570def get_pr_repo (num ):
5671 """Returns (owner, repo, num) for the PR number for this git repo.
You can’t perform that action at this time.
0 commit comments