File tree Expand file tree Collapse file tree 3 files changed +994
-0
lines changed
Expand file tree Collapse file tree 3 files changed +994
-0
lines changed Original file line number Diff line number Diff line change 1010from ogr .exceptions import GithubAPIException , OgrNetworkError
1111from ogr .services import github as ogr_github
1212from ogr .services .base import BaseGitCommit
13+ from ogr .services .github .pull_request import GithubPullRequest
1314
1415
1516class GithubCommit (BaseGitCommit ):
@@ -26,6 +27,10 @@ def changes(self) -> "GithubCommitChanges":
2627 self ._changes = GithubCommitChanges (self )
2728 return self ._changes
2829
30+ def get_prs (self ) -> Iterable [GithubPullRequest ]:
31+ for pr in self ._raw_commit .get_pulls ():
32+ yield GithubPullRequest (pr , self .project )
33+
2934 @staticmethod
3035 def get (project : "ogr_github.GithubProject" , sha : str ) -> "GithubCommit" :
3136 try :
Original file line number Diff line number Diff line change @@ -22,3 +22,16 @@ def test_changes(self):
2222 commit = self .hello_world_project .get_commit ("f06fed9" )
2323 changes = commit .changes
2424 assert list (changes .files ) == ["LICENSE" , "README.md" ]
25+
26+ def test_get_prs (self ):
27+ # Commit with PR associated
28+ commit_with_one_pr = self .hello_world_project .get_commit ("0840e2d" )
29+ prs = commit_with_one_pr .get_prs ()
30+ assert prs
31+ assert len (prs ) == 1
32+ assert prs [0 ].id == 556
33+ # Commit with no PR
34+ commit_without_pr = self .hello_world_project .get_commit ("f2c98da" )
35+ prs = commit_without_pr .get_prs ()
36+ assert not prs
37+ # No test data for commit with multiple PRs
You can’t perform that action at this time.
0 commit comments