Skip to content

Commit 932cc6d

Browse files
authored
Merge pull request #27 from consideRatio/fail-early-on-missing-github-api-credentials
Fail early on missing GitHub api credentials
2 parents f8a631a + b59a2c8 commit 932cc6d

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

github_activity/graphql.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,18 @@ def __init__(self, query, display_progress=True, auth=None):
9292
self.query = query
9393

9494
# Authentication
95-
headers = {}
96-
auth = os.environ.get("GITHUB_ACCESS_TOKEN") if auth is None else auth
97-
if auth is not None:
98-
headers.update({"Authorization": "Bearer %s" % auth})
95+
auth = auth or os.environ.get("GITHUB_ACCESS_TOKEN")
96+
if not auth:
97+
raise ValueError(
98+
"Either the environment variable GITHUB_ACCESS_TOKEN or the "
99+
"--auth flag or must be used to pass a Personal Access Token "
100+
"needed by the GitHub API. You can generate a token at "
101+
"https://github.com/settings/tokens/new. Note that while "
102+
"working with a public repository, you don’t need to set any "
103+
"scopes on the token you create."
104+
)
105+
self.headers = {"Authorization": "Bearer %s" % auth}
99106

100-
self.headers = headers
101107
self.gql_template = gql_template
102108
self.display_progress = display_progress
103109

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_tags(tmpdir, file_regression):
2626
path_tmp = Path(tmpdir)
2727
path_output = path_tmp.joinpath("out.md")
2828

29-
url = "https://github.com/executablebookproject/sphinx-book-theme"
29+
url = "https://github.com/executablebooks/sphinx-book-theme"
3030

3131
# CLI with URL
3232
cmd = f"github-activity {url} -s v0.0.2 -u v0.0.4 -o {path_output}"

tests/test_cli/test_tags.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# v0.0.2...v0.0.4
2-
([full changelog](https://github.com/ExecutableBookProject/sphinx-book-theme/compare/v0.0.2...v0.0.4))
2+
([full changelog](https://github.com/executablebooks/sphinx-book-theme/compare/v0.0.2...v0.0.4))
33

44

55
## Merged PRs
6-
* moving expand_sections to a config value [#74](https://github.com/ExecutableBookProject/sphinx-book-theme/pull/74) ([@choldgraf](https://github.com/choldgraf))
6+
* moving expand_sections to a config value [#74](https://github.com/executablebooks/sphinx-book-theme/pull/74) ([@choldgraf](https://github.com/choldgraf))
77

88
## Contributors to this release
9-
([GitHub contributors page for this release](https://github.com/ExecutableBookProject/sphinx-book-theme/graphs/contributors?from=2020-04-22&to=2020-04-24&type=c))
9+
([GitHub contributors page for this release](https://github.com/executablebooks/sphinx-book-theme/graphs/contributors?from=2020-04-22&to=2020-04-24&type=c))
1010

11-
[@choldgraf](https://github.com/search?q=repo%3AExecutableBookProject%2Fsphinx-book-theme+involves%3Acholdgraf+updated%3A2020-04-22..2020-04-24&type=Issues)
11+
[@choldgraf](https://github.com/search?q=repo%3Aexecutablebooks%2Fsphinx-book-theme+involves%3Acholdgraf+updated%3A2020-04-22..2020-04-24&type=Issues)

0 commit comments

Comments
 (0)