Skip to content

Commit

Permalink
git-to-freshports-xml.py: catch up for pygit2-1.15 changes
Browse files Browse the repository at this point in the history
From https://github.com/libgit2/pygit2/blob/master/CHANGELOG.md#1150-2024-05-18
under Breaking changes:

* Remove deprecated object.hex, use str(object.id)
* Remove deprecated object.oid, use object.id

This code now requires pygit2>=1.15.0
  • Loading branch information
dlangille committed Oct 19, 2024
1 parent 2e9abf7 commit 3092037
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions git-to-freshports/git-to-freshports-xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def commit_range(repo: pygit2.Repository, commit_range: str):
start_commit = repo.revparse_single(start_commit_ref)
end_commit = repo.revparse_single(end_commit_ref)

walker = repo.walk(end_commit.oid)
walker = repo.walk(end_commit.id)
walker.simplify_first_parent() # Avoid wandering off to merged branches. Same as 'git log --first-parent'

result = []
Expand Down Expand Up @@ -171,7 +171,7 @@ def main():

for order_number, commit in enumerate(commits):
commit: pygit2.Commit
log.info(f"Processing commit '{commit.hex} {commit.message.splitlines()[0]}'")
log.info(f"Processing commit '{str(commit.id)} {commit.message.splitlines()[0]}'")
root = ET.Element('UPDATES', Version=FORMAT_VERSION, Source='git')
update = ET.SubElement(root, 'UPDATE')

Expand All @@ -193,11 +193,11 @@ def main():
commit_branches = list(repo.branches.remote.with_commit(commit))
commit_branches_num = len(commit_branches)
if commit_branches_num == 0:
log.error(f"Unable to get branch name for commit {commit.hex}. "
log.error(f"Unable to get branch name for commit {str(commit.id)}. "
f"Make sure that the local tracking branch exists for the remote branch.")
continue
elif commit_branches_num > 1:
log.warning(f"Ambiguity in getting branch name for commit {commit.hex}. Got branches: {commit_branches}."
log.warning(f"Ambiguity in getting branch name for commit {str(commit.id)}. Got branches: {commit_branches}."
f"Using the first one: {commit_branches[0]}")
ET.SubElement(update, 'OS', Repo=config['repo'], Id=config['os'], Branch=commit_branches[0])

Expand All @@ -214,7 +214,7 @@ def main():
ET.SubElement(people, 'AUTHOR', AuthorName=f"{commit.author.name}", AuthorEmail=f"{commit.author.email}")

log.debug("Writing commit hash")
ET.SubElement(update, 'COMMIT', Hash=commit.hex, HashShort=commit.short_id,
ET.SubElement(update, 'COMMIT', Hash=str(commit.id), HashShort=commit.short_id,
Subject=commit.message.splitlines()[0], EncodingLoses="false", Repository=config['repo'])

files = ET.SubElement(update, 'FILES')
Expand Down Expand Up @@ -244,7 +244,7 @@ def main():

file_name = (f"{commit_datetime.year}.{commit_datetime.month:02d}.{commit_datetime.day:02d}."
f"{commit_datetime.hour:02d}.{commit_datetime.minute:02d}.{commit_datetime.second:02d}."
f"{order_number:06d}.{commit.hex}.xml")
f"{order_number:06d}.{str(commit.id)}.xml")
file_mode = 'wb' if config['force'] else 'xb'
log.debug("Dumping XML")
try:
Expand Down

1 comment on commit 3092037

@dlangille
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.