File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 11import urllib .parse
2+ import os
23
34from git import Repo
45
@@ -14,7 +15,18 @@ def __init__(self, path: str):
1415 self .repo = Repo (path )
1516 assert self .repo
1617 self .head = self .repo .head
17- self .commit = self .head .commit
18+
19+ # Use GITHUB_SHA if available, otherwise fall back to head commit
20+ github_sha = os .getenv ('GITHUB_SHA' )
21+ if github_sha :
22+ try :
23+ self .commit = self .repo .commit (github_sha )
24+ except Exception as error :
25+ log .debug (f"Failed to get commit from GITHUB_SHA: { error } " )
26+ self .commit = self .head .commit
27+ else :
28+ self .commit = self .head .commit
29+
1830 self .repo_name = self .repo .remotes .origin .url .split ('.git' )[0 ].split ('/' )[- 1 ]
1931 try :
2032 self .branch = self .head .reference
Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ def from_env(cls) -> 'GithubConfig':
4141 log .error ("Unable to get Github API Token from GH_API_TOKEN" )
4242 sys .exit (2 )
4343
44+ # Add debug logging
45+ sha = os .getenv ('GITHUB_SHA' , '' )
46+ log .debug (f"Loading SHA from GITHUB_SHA: { sha } " )
47+
4448 repository = os .getenv ('GITHUB_REPOSITORY' , '' )
4549 owner = os .getenv ('GITHUB_REPOSITORY_OWNER' , '' )
4650 if '/' in repository :
You can’t perform that action at this time.
0 commit comments