This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git
The following commit(s) were added to refs/heads/main by this push:
new f389548 Fix a problem with getting commit hashes
f389548 is described below
commit f389548591458084d9852b503c76e67a9c404180
Author: Sean B. Palmer <[email protected]>
AuthorDate: Tue May 6 16:48:54 2025 +0100
Fix a problem with getting commit hashes
---
migrations/env.py | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/migrations/env.py b/migrations/env.py
index ed29ebe..a4d1386 100644
--- a/migrations/env.py
+++ b/migrations/env.py
@@ -50,15 +50,19 @@ sync_sqlalchemy_url = f"sqlite:///{absolute_db_path}"
def get_short_commit_hash(project_root_path: str) -> str:
- """Get the short, eight character, git commit hash."""
- process = subprocess.run(
- ["git", "rev-parse", "--short=8", "HEAD"],
- capture_output=True,
- text=True,
- cwd=project_root_path,
- check=True,
- )
- return process.stdout.strip()
+ """Get an eight character git commit hash, or a fallback."""
+ try:
+ process = subprocess.run(
+ ["git", "rev-parse", "--short=8", "HEAD"],
+ capture_output=True,
+ text=True,
+ cwd=project_root_path,
+ check=True,
+ )
+ return process.stdout.strip()
+ except (subprocess.CalledProcessError, FileNotFoundError):
+ # Return a placeholder if the git command fails
+ return "00000000"
def process_revision_directives_custom_naming(
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]