diff --git a/stscraper/github.py b/stscraper/github.py index aa51a17..1c08efd 100644 --- a/stscraper/github.py +++ b/stscraper/github.py @@ -197,6 +197,12 @@ def repo_commits(self, repo_slug): # https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository return repo_slug + @api('repos/%s/commits/%s') + def repo_commit(self, repo_slug, commit_hash): + """Get details for a single commit.""" + # https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-a-commit + return repo_slug, commit_hash + @api('repos/%s/pulls', paginate=True, state='all') def repo_pulls(self, repo_slug): """Get all repository pull requests. diff --git a/test.py b/test.py index 923f627..d8c7fd6 100755 --- a/test.py +++ b/test.py @@ -54,7 +54,7 @@ def test_check_print_limits(self): finally: sys.stdout = old_stdout - def _test_commits(self, commit): + def _test_commit(self, commit): self.assertIsInstance(commit, dict) for prop in ('sha', 'commit', 'author', 'committer', 'parents'): self.assertIn(prop, commit, @@ -156,7 +156,13 @@ def test_repo_commits(self): commits = self.api.repo_commits(self.repo_address) self.assertIsInstance(commits, Generator) commit = next(commits) - self._test_commits(commit) + self._test_commit(commit) + + def test_repo_commit(self): + commit = self.api.repo_commit( + 'cmustrudel/strudel.scraper', '6adbcd5fbbee057dae4802a2b7099f3f35999e4a') + self.assertIsInstance(commit, dict) + self._test_commit(commit) def test_repo_pulls(self): pulls = self.api.repo_pulls(self.repo_address) @@ -178,7 +184,7 @@ def test_pull_request_commits(self): commits = self.api.pull_request_commits(self.repo_address, 22457) self.assertIsInstance(commits, Generator) commit = next(commits) - self._test_commits(commit) + self._test_commit(commit) def test_issue_comments(self): comments = self.api.issue_comments(self.repo_address, 22473)