File tree Expand file tree Collapse file tree 4 files changed +27
-9
lines changed Expand file tree Collapse file tree 4 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -47,15 +47,17 @@ You can also use `webdiff` to view GitHub pull requests:
4747
4848This will download the files relevant to the Pull Request and run ` webdiff ` .
4949
50- If you run into GitHub API quota limits, you can set your credentials in a ` .githubrc ` file:
50+ If you run into GitHub API quota limits or you'd like to use webdiff with
51+ private repos, you can set your credentials in a ` .githubrc ` file:
5152
5253```
5354user.login: yourusername
54- user.password: yourpassword
55+ user.token: your-personal-access-tokens
5556```
5657
57- Make sure you chmod this file to only be readable by yourself. In the future
58- we'll support [ Oauth] [ ] .
58+ Make sure you chmod this file to only be readable by yourself. You can generate
59+ a personal access token for webdiff via github.com → profile → Settings →
60+ Personal access tokens. Make sure to grant all the "repo" privileges.
5961
6062
6163Development
Original file line number Diff line number Diff line change 1616 ],
1717 "dependencies" : {
1818 "jquery" : " ~2.1.1" ,
19- "highlightjs" : " ~8.0 .0" ,
19+ "highlightjs" : " ~9.2 .0" ,
2020 "underscore" : " ~1.6.0" ,
2121 "react" : " ~0.12.2" ,
2222 "react-router" : " ~0.11.6"
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ flask==0.10.1
22nose
33PyGithub == 1.25.2
44pillow
5+ requests
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