Skip to content

Commit

Permalink
fix fix package digest when running from source tree
Browse files Browse the repository at this point in the history
  • Loading branch information
aszs committed Oct 30, 2024
1 parent 08f0946 commit b8c0898
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def test_server_export_remote():

dep_commit = GitRepo(Repo("application-blueprint/std")).revision
etag = server._make_etag(hex(int(last_commit, 16)
^ int(get_package_digest(True), 16)
^ int(get_package_digest(), 16)
^ int(dep_commit, 16)))
# # check that this public project (no auth header sent) was cached
res = requests.get(
Expand Down
2 changes: 1 addition & 1 deletion unfurl/server/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ class CacheValue(NamedTuple):
last_commit_date: int

def make_etag(self) -> str:
etag = int(self.last_commit, 16) ^ int(get_package_digest(True) or "0", 16)
etag = int(self.last_commit, 16) ^ int(get_package_digest() or "0", 16)
for dep in self.deps.values():
for last_commit in dep.last_commits:
if last_commit:
Expand Down
9 changes: 3 additions & 6 deletions unfurl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
_package_digest: Optional[str] = None


def get_package_digest(commit_only=False) -> str:
def get_package_digest() -> str:
global _package_digest
if _package_digest is not None:
return _package_digest
Expand All @@ -82,11 +82,8 @@ def get_package_digest(commit_only=False) -> str:
basedir = os.path.dirname(_basepath)
if os.path.isdir(os.path.join(basedir, ".git")):
repo = Repo(basedir)
if commit_only:
# same as pbr's git_version
_package_digest = repo.git.log(n=1, pretty="format:%h")
else:
_package_digest = repo.git.describe("--dirty", "--always", "--match=v*")
# same as pbr's git_version
_package_digest = repo.git.log(n=1, pretty="format:%h")
else:
_package_digest = ""
pkg_files = files("unfurl")
Expand Down

0 comments on commit b8c0898

Please sign in to comment.