Skip to content

Commit

Permalink
slightly polish previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Nov 10, 2023
1 parent abd8a4f commit 1b0a5c6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions setupsrc/pypdfium2_setup/build_pdfium.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,20 @@ def _dl_unbundler():
url_request.urlretrieve(tool_url, tool_file)


def _emulate_git_describe(log):
# we didn't manage to get git describe working reliably with chromium's branch heads and the awkward state the repo's in, so emulate git describe on our own
def _walk_refs(log):
for i, line in enumerate(log.split("\n")):
for ref in line.split(", "):
match = re.match(r"origin/chromium/(\d+)", ref)
match = re.fullmatch(r"origin/chromium/(\d+)", ref.strip())
if match:
return int(match.group(1)), i
assert False, "Failed to find versioned commit - log too small?"


def identify_pdfium():
# we didn't manage to get git describe working reliably with chromium's branch heads and the awkward state the repo's in, so emulate git describe on our own
# FIXME avoid static number of commits - need a better way to determine latest version and commit count diff
log = run_cmd(["git", "log", "-100", "--pretty=%D"], cwd=PDFiumDir, capture=True)
v_short, n_commits = _emulate_git_describe(log)
v_short, n_commits = _walk_refs(log)
if n_commits:
hash = "g" + run_cmd(["git", "rev-parse", "--short", "HEAD"], cwd=PDFiumDir, capture=True)
else:
Expand Down

0 comments on commit 1b0a5c6

Please sign in to comment.