Skip to content

Commit

Permalink
Rename git describe functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Oct 7, 2023
1 parent 530ec9e commit 34397f5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def run(self, *args, **kwargs):
helpers_info["n_commits"] = math.inf
helpers_info["hash"] = "editable"
helpers_info["dirty"] = True
helpers_info["version"] = craft_helpers_id(helpers_info, mode="py")
helpers_info["version"] = merge_git_describe(helpers_info, mode="py")
write_json(ModuleDir_Helpers/VersionFN, helpers_info)

build_py_orig.run(self, *args, **kwargs)
Expand All @@ -65,8 +65,8 @@ def main():

ver_file = ModuleDir_Helpers/VersionFN
if HAVE_GIT_REPO:
helpers_info = read_helpers_ver()
helpers_info["version"] = craft_helpers_id(helpers_info, mode="py")
helpers_info = parse_git_describe()
helpers_info["version"] = merge_git_describe(helpers_info, mode="py")
else: # sdist compat
log("Warning: Local git repo not available, so we depend on an existing version file.")
assert ver_file.exists(), f"{'/'.join(ver_file.parts[-2:])} does not exist."
Expand Down
8 changes: 4 additions & 4 deletions setupsrc/pypdfium2_setup/autorelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,20 +204,20 @@ def main():
latest_pdfium = PdfiumVer.get_latest()
increments = read_json(IncrementsFile, with_checksum=False)
prev_pdfium = read_json(VerFile_Pdfium)["build"]
prev_helpers = read_helpers_ver()
prev_helpers = parse_git_describe()
(c_updates, new_pdfium), (py_updates, new_helpers) = \
do_versioning(increments, prev_pdfium, prev_helpers, latest_pdfium)

prev_tag = craft_helpers_id(prev_helpers, mode=None)
new_tag = craft_helpers_id(new_helpers, mode=None)
prev_tag = merge_git_describe(prev_helpers, mode=None)
new_tag = merge_git_describe(new_helpers, mode=None)

update_refbindings(latest_pdfium)
summary = get_changelog_staging(new_helpers["beta"])
log_changes(summary, prev_pdfium, new_pdfium, new_tag, new_helpers["beta"])
if args.register:
register_changes(new_tag)
# Verify the next version parses correctly and reading the record returns the info we wrote
assert read_helpers_ver() == new_helpers
assert parse_git_describe() == new_helpers
make_releasenotes(summary, prev_pdfium, new_pdfium, prev_tag, new_tag, c_updates)


Expand Down
6 changes: 3 additions & 3 deletions setupsrc/pypdfium2_setup/packaging_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def write_pdfium_info(dir, version, origin, flags=set()):
write_json(dir/VersionFN, info)


def read_helpers_ver():
def parse_git_describe():

info = dict()
descriptor = run_cmd(["git", "describe", "--dirty"], capture=True, cwd=ProjectDir)
Expand All @@ -210,12 +210,12 @@ def read_helpers_ver():
for value, (key, cast) in zip(id_parts, schema):
info[key] = cast(value)

assert craft_helpers_id(info, mode="git") == descriptor
assert merge_git_describe(info, mode="git") == descriptor

return info


def craft_helpers_id(info, mode):
def merge_git_describe(info, mode):

tag = f"{info['major']}.{info['minor']}.{info['patch']}"
if info['beta'] is not None:
Expand Down

0 comments on commit 34397f5

Please sign in to comment.