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 1
1
import urllib .parse
2
+ import os
2
3
3
4
from git import Repo
4
5
@@ -14,7 +15,18 @@ def __init__(self, path: str):
14
15
self .repo = Repo (path )
15
16
assert self .repo
16
17
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
+
18
30
self .repo_name = self .repo .remotes .origin .url .split ('.git' )[0 ].split ('/' )[- 1 ]
19
31
try :
20
32
self .branch = self .head .reference
Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ def from_env(cls) -> 'GithubConfig':
41
41
log .error ("Unable to get Github API Token from GH_API_TOKEN" )
42
42
sys .exit (2 )
43
43
44
+ # Add debug logging
45
+ sha = os .getenv ('GITHUB_SHA' , '' )
46
+ log .debug (f"Loading SHA from GITHUB_SHA: { sha } " )
47
+
44
48
repository = os .getenv ('GITHUB_REPOSITORY' , '' )
45
49
owner = os .getenv ('GITHUB_REPOSITORY_OWNER' , '' )
46
50
if '/' in repository :
You can’t perform that action at this time.
0 commit comments