2
0
Эх сурвалжийг харах

include git refs and HEAD file in docker images to allow GIT_SHA of builds to show in version output

Nick Sweeting 1 жил өмнө
parent
commit
b0da386793

+ 3 - 1
.dockerignore

@@ -5,10 +5,12 @@ __pycache__/
 .mypy_cache/
 .mypy_cache/
 .pytest_cache/
 .pytest_cache/
 .github/
 .github/
-.git/
 .pdm-build/
 .pdm-build/
 .pdm-python
 .pdm-python
 .eggs/
 .eggs/
+.git/
+!.git/HEAD
+!.git/refs/heads/*
 
 
 venv/
 venv/
 .venv/
 .venv/

+ 1 - 1
archivebox/config.py

@@ -399,7 +399,7 @@ def get_version(config):
 
 
 def get_commit_hash(config) -> Optional[str]:
 def get_commit_hash(config) -> Optional[str]:
     try:
     try:
-        git_dir = config['PACKAGE_DIR'] / '../'
+        git_dir = config['PACKAGE_DIR'] / '../.git'
         ref = (git_dir / 'HEAD').read_text().strip().split(' ')[-1]
         ref = (git_dir / 'HEAD').read_text().strip().split(' ')[-1]
         commit_hash = git_dir.joinpath(ref).read_text().strip()
         commit_hash = git_dir.joinpath(ref).read_text().strip()
         return commit_hash
         return commit_hash