Skip to content

Commit 0366d31

Browse files
committed
Merge pull request #107 from danvk/updates
OAuth and highlight.js version bumps
2 parents e6751b4 + 58420cb commit 0366d31

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,17 @@ You can also use `webdiff` to view GitHub pull requests:
4747

4848
This 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
```
5354
user.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

6163
Development

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
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"

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ flask==0.10.1
22
nose
33
PyGithub==1.25.2
44
pillow
5+
requests

webdiff/github_fetcher.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff 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):
5163
class UnknownPullRequestError(Exception):
5264
pass
5365

66+
class OnlyPasswordOrToken(Exception):
67+
pass
68+
5469

5570
def get_pr_repo(num):
5671
"""Returns (owner, repo, num) for the PR number for this git repo.

0 commit comments

Comments
 (0)