Skip to content

Commit 2a4f395

Browse files
authored
Add path option to GH service get_commit_details (#25)
1 parent 59482c9 commit 2a4f395

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
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.3
2+
3+
- [IMPROVED] Github service `get_commit_details` now take `path` as an optional argument.
4+
15
# 1.2.2
26

37
- [FIXED] Github service branch protection method now returns "required_signatures" content.

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.2.2'
17+
__version__ = '1.2.3'

compliance/utils/services/github.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -497,26 +497,24 @@ 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, branch='master'):
500+
def get_commit_details(self, repo, since, branch='master', path=None):
501501
"""
502-
Retrieve a repository's commit details since a given date/time.
502+
Retrieve a repository branch'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.
506506
:param branch: the branch as a string. Defaults to master.
507+
:param path: if provided, only commits for the path will be returned.
507508
508509
:returns: the repo branch's commit details since a given date/time.
509510
"""
510511
self.session.headers.update(
511512
{'Accept': 'application/vnd.github.v3+json'}
512513
)
513-
return self._make_request(
514-
'get',
515-
f'repos/{repo}/commits',
516-
params={
517-
'since': since.strftime('%Y-%m-%dT%H:%M:%SZ'), 'sha': branch
518-
}
519-
)
514+
opts = {'since': since.strftime('%Y-%m-%dT%H:%M:%SZ'), 'sha': branch}
515+
if path:
516+
opts['path'] = path
517+
return self._make_request('get', f'repos/{repo}/commits', params=opts)
520518

521519
def get_branch_protection_details(self, repo, branch='master'):
522520
"""

0 commit comments

Comments
 (0)