File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1111__license__ = 'MIT'
1212__author__ = 'Kenneth Reitz'
1313
14+
15+ import envoy
16+
1417from .api import Github , settings
1518
1619
20+
1721def no_auth ():
1822 """Returns an un-authenticated Github object."""
1923
@@ -33,4 +37,25 @@ def enable_auth(*args, **kwargs):
3337 gh .is_authenticated = True
3438 gh ._requests_pre_hook = enable_auth
3539
40+ return gh
41+
42+
43+
44+ def git_config ():
45+ """Returns an authenticated Github object, via HTTP Basic.
46+
47+ GitHub API token is taken from `git config`.
48+ """
49+
50+ username = envoy .run ('git config github.user' ).std_out .strip ()
51+ token = envoy .run ('git config github.token' ).std_out .strip ()
52+
53+ def enable_auth (* args , ** kwargs ):
54+ kwargs ['auth' ] = (username , token )
55+ return args , kwargs
56+
57+ gh = Github ()
58+ gh .is_authenticated = True
59+ gh ._requests_pre_hook = enable_auth
60+
3661 return gh
You can’t perform that action at this time.
0 commit comments