Skip to content

Commit

Permalink
Merge pull request #107 from danvk/updates
Browse files Browse the repository at this point in the history
OAuth and highlight.js version bumps
  • Loading branch information
danvk committed Mar 17, 2016
2 parents e6751b4 + 58420cb commit 0366d31
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ You can also use `webdiff` to view GitHub pull requests:


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


If you run into GitHub API quota limits, you can set your credentials in a `.githubrc` file: If you run into GitHub API quota limits or you'd like to use webdiff with
private repos, you can set your credentials in a `.githubrc` file:


``` ```
user.login: yourusername user.login: yourusername
user.password: yourpassword user.token: your-personal-access-tokens
``` ```


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




Development Development
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
], ],
"dependencies": { "dependencies": {
"jquery": "~2.1.1", "jquery": "~2.1.1",
"highlightjs": "~8.0.0", "highlightjs": "~9.2.0",
"underscore": "~1.6.0", "underscore": "~1.6.0",
"react": "~0.12.2", "react": "~0.12.2",
"react-router": "~0.11.6" "react-router": "~0.11.6"
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ flask==0.10.1
nose nose
PyGithub==1.25.2 PyGithub==1.25.2
pillow pillow
requests
23 changes: 19 additions & 4 deletions webdiff/github_fetcher.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,11 +36,23 @@ def simple_fallback(message=None):
k, v = line.split(': ', 1) k, v = line.split(': ', 1)
kvs[k] = v kvs[k] = v


if not kvs.get('user.login'): login = kvs.get('user.login')
if not login:
return simple_fallback('.githubrc missing user.login. Using anonymous API access.') return simple_fallback('.githubrc missing user.login. Using anonymous API access.')
if not kvs.get('user.password'):
return simple_fallback('.githubrc missing user.password. Using anonymous API access.') password = kvs.get('user.password')
return Github(kvs['user.login'], kvs['user.password']) token = kvs.get('user.token')

if password and token:
raise OnlyPasswordOrToken('Only specify user.token or user.password '
'in your .githubrc file (got both)')

auth = token or password

if not auth:
return simple_fallback('.githubrc has neither user.password nor user.token.'
'Using anonymous API access.')
return Github(login, auth)
else: else:
return Github() return Github()


Expand All @@ -51,6 +63,9 @@ class NoRemoteError(Exception):
class UnknownPullRequestError(Exception): class UnknownPullRequestError(Exception):
pass pass


class OnlyPasswordOrToken(Exception):
pass



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

0 comments on commit 0366d31

Please sign in to comment.