Skip to content

Commit 66eff19

Browse files
committed
fixing the source of the commit sha
1 parent 4966365 commit 66eff19

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

socketsecurity/core/git_interface.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import urllib.parse
2+
import os
23

34
from 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

socketsecurity/core/scm/github.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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:

0 commit comments

Comments
 (0)