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
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`.

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.password: yourpassword
user.token: your-personal-access-tokens
```

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


Development
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Expand Up @@ -16,7 +16,7 @@
],
"dependencies": {
"jquery": "~2.1.1",
"highlightjs": "~8.0.0",
"highlightjs": "~9.2.0",
"underscore": "~1.6.0",
"react": "~0.12.2",
"react-router": "~0.11.6"
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -2,3 +2,4 @@ flask==0.10.1
nose
PyGithub==1.25.2
pillow
requests
23 changes: 19 additions & 4 deletions webdiff/github_fetcher.py
Expand Up @@ -36,11 +36,23 @@ def simple_fallback(message=None):
k, v = line.split(': ', 1)
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.')
if not kvs.get('user.password'):
return simple_fallback('.githubrc missing user.password. Using anonymous API access.')
return Github(kvs['user.login'], kvs['user.password'])

password = kvs.get('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:
return Github()

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

class OnlyPasswordOrToken(Exception):
pass


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

0 comments on commit 0366d31

Please sign in to comment.