-
-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make commit grabber use GIT_REV env var if set
Co-authored-by: nekomona <nekomona@163.com>
- Loading branch information
1 parent
1ad5d72
commit 594d3c0
Showing
1 changed file
with
11 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import subprocess | ||
import os | ||
|
||
revision = "00000000000000000000000000000000000000000" | ||
revision = "" | ||
|
||
env_rev = os.environ.get("GIT_REV") | ||
if env_rev != "": | ||
if not env_rev is None and env_rev != "": | ||
revision = env_rev | ||
|
||
try: | ||
revision = ( | ||
subprocess.check_output(["git", "rev-parse", "HEAD"]) | ||
.strip() | ||
.decode("utf-8") | ||
) | ||
except Exception: | ||
revision = "NOT_GIT" | ||
else: | ||
try: | ||
revision = ( | ||
subprocess.check_output(["git", "rev-parse", "HEAD"]) | ||
.strip() | ||
.decode("utf-8") | ||
) | ||
except Exception: | ||
revision = "NOT_GIT" | ||
|
||
print(f"'-DGIT_REV=\"{revision}\"'") |