Skip to content

Commit

Permalink
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 2909b0f commit 8ca6611
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
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), 16)
etag = int(self.last_commit, 16) ^ int(get_package_digest(True) or "0", 16)
for dep in self.deps.values():
for last_commit in dep.last_commits:
if last_commit:
Expand Down
15 changes: 9 additions & 6 deletions unfurl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ def get_package_digest(commit_only=False) -> str:
_package_digest = repo.git.log(n=1, pretty="format:%h")
else:
_package_digest = repo.git.describe("--dirty", "--always", "--match=v*")

try:
pbr = [p for p in files("unfurl") if "pbr.json" in str(p)][0] # type: ignore # Ignored because of the try/except
_package_digest = json.loads(pbr.read_text())["git_version"]
except Exception:
else:
_package_digest = ""
return cast(str, _package_digest)
pkg_files = files("unfurl")
if pkg_files:
try:
pbr = [p for p in pkg_files if "pbr.json" in str(p)][0]
_package_digest = json.loads(pbr.read_text())["git_version"]
except Exception:
_package_digest = ""
return str(_package_digest)


class UnfurlError(Exception):
Expand Down

0 comments on commit 8ca6611

Please sign in to comment.