-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Motivation To be able to link a pipeline rune with the code that has executed it, we want to log the git sha of the last commit in the pipeline logfile.
- Loading branch information
1 parent
beb3769
commit 3dadeac
Showing
2 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import subprocess | ||
from pathlib import Path | ||
|
||
|
||
def get_head_sha() -> str: | ||
"""When launched in a git repository, return the SHA of the current HEAD.""" | ||
|
||
result = subprocess.run( | ||
["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True, cwd=Path(__file__).parent | ||
) | ||
assert result.returncode == 0, f"Failed to get HEAD SHA: {result.stderr}, {result.stdout}" | ||
return result.stdout.strip() |