From 0b950b3253b5ccef6f324aede8e9e1f2e6723822 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Tue, 28 Mar 2023 02:58:49 -0600 Subject: [PATCH] make get_commit_hash more precisce by using exact ref --- archivebox/config.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/archivebox/config.py b/archivebox/config.py index 775be8e4..4e434c12 100644 --- a/archivebox/config.py +++ b/archivebox/config.py @@ -393,7 +393,10 @@ def get_version(config): def get_commit_hash(config): try: - return list((config['PACKAGE_DIR'] / '../.git/refs/heads/').glob('*'))[0].read_text().strip() + git_dir = config['PACKAGE_DIR'] / '../') + ref = (git_dir / 'HEAD').read_text().strip().split(' ')[-1] + commit_hash = git_dir.joinpath(ref).read_text().strip() + return commit_hash except Exception: return None