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 numberOriginal file lineDiff line numberDiff line change
@@ -47,15 +47,17 @@ You can also use `webdiff` to view GitHub pull requests:
47

47

48
This will download the files relevant to the Pull Request and run `webdiff`.
48
This will download the files relevant to the Pull Request and run `webdiff`.
49

49

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:
51

52

52
```
53
```
53
user.login: yourusername
54
user.login: yourusername
54-
user.password: yourpassword
55+
user.token: your-personal-access-tokens
55
```
56
```
56

57

57-
Make sure you chmod this file to only be readable by yourself. In the future
58+
Make sure you chmod this file to only be readable by yourself. You can generate
58-
we'll support [Oauth][].
59+
a personal access token for webdiff via github.com → profile → Settings →
60+
Personal access tokens. Make sure to grant all the "repo" privileges.
59

61

60

62

61
Development
63
Development

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -16,7 +16,7 @@
16
],
16
],
17
"dependencies": {
17
"dependencies": {
18
"jquery": "~2.1.1",
18
"jquery": "~2.1.1",
19-
"highlightjs": "~8.0.0",
19+
"highlightjs": "~9.2.0",
20
"underscore": "~1.6.0",
20
"underscore": "~1.6.0",
21
"react": "~0.12.2",
21
"react": "~0.12.2",
22
"react-router": "~0.11.6"
22
"react-router": "~0.11.6"

requirements.txt

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

webdiff/github_fetcher.py

Lines changed: 19 additions & 4 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -36,11 +36,23 @@ def simple_fallback(message=None):
36
k, v = line.split(': ', 1)
36
k, v = line.split(': ', 1)
37
kvs[k] = v
37
kvs[k] = v
38

38

39-
if not kvs.get('user.login'):
39+
login = kvs.get('user.login')
40+
if not login:
40
return simple_fallback('.githubrc missing user.login. Using anonymous API access.')
41
return simple_fallback('.githubrc missing user.login. Using anonymous API access.')
41-
if not kvs.get('user.password'):
42+
42-
return simple_fallback('.githubrc missing user.password. Using anonymous API access.')
43+
password = kvs.get('user.password')
43-
return Github(kvs['user.login'], kvs['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)
44
else:
56
else:
45
return Github()
57
return Github()
46

58

@@ -51,6 +63,9 @@ class NoRemoteError(Exception):
51
class UnknownPullRequestError(Exception):
63
class UnknownPullRequestError(Exception):
52
pass
64
pass
53

65

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

69

55
def get_pr_repo(num):
70
def get_pr_repo(num):
56
"""Returns (owner, repo, num) for the PR number for this git repo.
71
"""Returns (owner, repo, num) for the PR number for this git repo.

0 commit comments

Comments
 (0)