From b0da3867935f089a43aab0577c78daa066c03ecb Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Wed, 3 Jan 2024 18:59:45 -0800 Subject: [PATCH] include git refs and HEAD file in docker images to allow GIT_SHA of builds to show in version output --- .dockerignore | 4 +++- archivebox/config.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index f4c91a47..08408d22 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,10 +5,12 @@ __pycache__/ .mypy_cache/ .pytest_cache/ .github/ -.git/ .pdm-build/ .pdm-python .eggs/ +.git/ +!.git/HEAD +!.git/refs/heads/* venv/ .venv/ diff --git a/archivebox/config.py b/archivebox/config.py index ecdc46be..f32034ce 100644 --- a/archivebox/config.py +++ b/archivebox/config.py @@ -399,7 +399,7 @@ def get_version(config): def get_commit_hash(config) -> Optional[str]: try: - git_dir = config['PACKAGE_DIR'] / '../' + git_dir = config['PACKAGE_DIR'] / '../.git' ref = (git_dir / 'HEAD').read_text().strip().split(' ')[-1] commit_hash = git_dir.joinpath(ref).read_text().strip() return commit_hash