Skip to content

Commit 7b7dcd0

Browse files
authored
Add branch option to GH service for commit detail retrieval (#22)
1 parent 69382a0 commit 7b7dcd0

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.2.0
2+
3+
- [NEW] Added branch option to retrieving commit details from the Github service.
4+
15
# 1.1.0
26

37
- [NEW] Added repository details retrieval to Github service class.

compliance/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
# limitations under the License.
1515
"""Compliance automation package."""
1616

17-
__version__ = '1.1.0'
17+
__version__ = '1.2.0'

compliance/utils/services/github.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,22 +497,25 @@ def get_repo_details(self, repo):
497497
)
498498
return self._make_request('get', f'repos/{repo}')
499499

500-
def get_commit_details(self, repo, since):
500+
def get_commit_details(self, repo, since, branch='master'):
501501
"""
502502
Retrieve a repository's commit details since a given date/time.
503503
504504
:param repo: the organization/repository as a string.
505505
:param since: the starting date/time as a datetime.
506+
:param branch: the branch as a string. Defaults to master.
506507
507-
:returns: the repository's commit details since a given date/time.
508+
:returns: the repo branch's commit details since a given date/time.
508509
"""
509510
self.session.headers.update(
510511
{'Accept': 'application/vnd.github.v3+json'}
511512
)
512513
return self._make_request(
513514
'get',
514515
f'repos/{repo}/commits',
515-
params={'since': since.strftime('%Y-%m-%dT%H:%M:%SZ')}
516+
params={
517+
'since': since.strftime('%Y-%m-%dT%H:%M:%SZ'), 'sha': branch
518+
}
516519
)
517520

518521
def get_branch_protection_details(self, repo, branch='master'):

0 commit comments

Comments
 (0)