From 5d08936d42a98bdc3821b1b9a8ada82d3c8235d3 Mon Sep 17 00:00:00 2001 From: Rebecca N. Palmer Date: Apr 15 2026 17:17:23 +0000 Subject: [PATCH 1/11] fix(pygit2): Stop using .oid and .hex These no longer exist in pygit2 1.15+ The templates use .__str__() because str() does not work there --- diff --git a/dev-data.py b/dev-data.py index 295ed3a..361c56e 100644 --- a/dev-data.py +++ b/dev-data.py @@ -570,7 +570,7 @@ def add_content_git_repo(folder, branch="master"): except KeyError: pass if commit: - parents = [commit.oid.hex] + parents = [str(commit.id)] # Commits the files added tree = repo.index.write_tree() @@ -594,7 +594,7 @@ def add_content_git_repo(folder, branch="master"): except KeyError: pass if commit: - parents = [commit.oid.hex] + parents = [str(commit.id)] subfolder = os.path.join("folder1", "folder2") if not os.path.exists(os.path.join(newfolder, subfolder)): diff --git a/pagure/api/fork.py b/pagure/api/fork.py index 3376d14..2a5b9c1 100644 --- a/pagure/api/fork.py +++ b/pagure/api/fork.py @@ -1605,7 +1605,7 @@ def api_pull_request_create(repo, username=None, namespace=None): ) if orig_commit: - orig_commit = orig_commit.oid.hex + orig_commit = str(orig_commit.id) initial_comment = None # This value is optional, check first if it's filled @@ -1614,8 +1614,8 @@ def api_pull_request_create(repo, username=None, namespace=None): commit_start = commit_stop = None if diff_commits: - commit_stop = diff_commits[0].oid.hex - commit_start = diff_commits[-1].oid.hex + commit_stop = str(diff_commits[0].id) + commit_start = str(diff_commits[-1].id) request = pagure.lib.query.new_pull_request( flask.g.session, @@ -1727,7 +1727,7 @@ def api_pull_request_diffstats(repo, requestid, username=None, namespace=None): try: for commit in repo_obj.walk(commitid, pygit2.GIT_SORT_NONE): diff_commits.append(commit) - if commit.oid.hex == request.commit_start: + if str(commit.id) == request.commit_start: break except KeyError: # This happens when repo.walk() cannot find commitid @@ -1736,19 +1736,19 @@ def api_pull_request_diffstats(repo, requestid, username=None, namespace=None): if diff_commits: # Ensure the first commit in the PR as a parent, otherwise # point to it - start = diff_commits[-1].oid.hex + start = str(diff_commits[-1].id) if diff_commits[-1].parents: - start = diff_commits[-1].parents[0].oid.hex + start = str(diff_commits[-1].parents[0].id) # If the start and the end commits are the same, it means we are, # dealing with one commit that has no parent, so just diff that # one commit - if start == diff_commits[0].oid.hex: + if start == str(diff_commits[0].id): diff = diff_commits[0].tree.diff_to_tree(swap=True) else: diff = repo_obj.diff( repo_obj.revparse_single(start), - repo_obj.revparse_single(diff_commits[0].oid.hex), + repo_obj.revparse_single(str(diff_commits[0].id)), ) else: try: diff --git a/pagure/api/project.py b/pagure/api/project.py index 02991fd..834bbef 100644 --- a/pagure/api/project.py +++ b/pagure/api/project.py @@ -920,7 +920,7 @@ def api_view_file( raise pagure.exceptions.APIError( 404, error_code=APIERROR.EFILENOTFOUND ) - content = repo_obj[content.oid] + content = repo_obj[content.id] else: content = commit @@ -2220,10 +2220,10 @@ def api_commit_info(repo, commit_hash, username=None, namespace=None): "committer": commit_obj.committer.name, "commit_time": commit_obj.commit_time, "commit_time_offset": commit_obj.commit_time_offset, - "hash": commit_obj.hex, + "hash": str(commit_obj.id), "message": commit_obj.message, - "parent_ids": [h.hex for h in commit_obj.parent_ids], - "tree_id": commit_obj.tree_id.hex, + "parent_ids": [str(h.id) for h in commit_obj.parent_ids], + "tree_id": str(commit_obj.tree_id), } return flask.jsonify(info) diff --git a/pagure/docs_server.py b/pagure/docs_server.py index 4aa422d..31be4e5 100644 --- a/pagure/docs_server.py +++ b/pagure/docs_server.py @@ -100,7 +100,7 @@ def __get_tree(repo_obj, tree, filepath, index=0, extended=False): filepath.append("") return __get_tree( repo_obj, - repo_obj[element.oid], + repo_obj[element.id], filepath, index=index + 1, extended=True, @@ -126,7 +126,7 @@ def __get_tree_and_content(repo_obj, commit, path): if blob_or_tree is None: return (tree_obj, None, None) - if not repo_obj[blob_or_tree.oid]: + if not repo_obj[blob_or_tree.id]: # Not tested and no idea how to test it, but better safe than sorry flask.abort(404, description="File not found") @@ -139,7 +139,7 @@ def __get_tree_and_content(repo_obj, commit, path): if is_file: filename = blob_or_tree.name name, ext = os.path.splitext(filename) - blob_obj = repo_obj[blob_or_tree.oid] + blob_obj = repo_obj[blob_or_tree.id] if not is_binary_string(blob_obj.data): try: content, safe = pagure.doc_utils.convert_readme( diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py index 45874c4..19e697c 100644 --- a/pagure/internal/__init__.py +++ b/pagure/internal/__init__.py @@ -606,20 +606,20 @@ def get_branches_of_commit(): if compare_branch: merge_commit_obj = repo_obj.merge_base( - compare_branch.peel().hex, branch.peel().hex + str(compare_branch.peel().id), str(branch.peel().id) ) if merge_commit_obj: - merge_commit = merge_commit_obj.hex + merge_commit = str(merge_commit_obj) - repo_commit = repo_obj[branch.peel().hex] + repo_commit = repo_obj[str(branch.peel().id)] for commit in repo_obj.walk( - repo_commit.oid.hex, pygit2.GIT_SORT_NONE + str(repo_commit.id), pygit2.GIT_SORT_NONE ): - if commit.oid.hex == merge_commit: + if str(commit.id) == merge_commit: break - if commit.oid.hex == commit_id: + if str(commit.id) == commit_id: branches.append(branchname) break @@ -690,7 +690,7 @@ def get_branches_head(): if not repo_obj.is_empty and len(repo_obj.listall_branches()) > 1: for branchname in repo_obj.listall_branches(): branch = repo_obj.lookup_branch(branchname) - branches[branchname] = branch.peel().hex + branches[branchname] = str(branch.peel().id) # invert the dict heads = collections.defaultdict(list) diff --git a/pagure/lib/git.py b/pagure/lib/git.py index e10e738..64dd6ff 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -126,7 +126,7 @@ Subject: {subject} {patch} """.format( - commit=commit.oid.hex, + commit=str(commit.id), author_name=commit.author.name, author_email=commit.author.email, date=datetime.datetime.utcfromtimestamp( @@ -241,7 +241,7 @@ def _update_git(obj, repo): # See if there is a parent to this commit parent = None try: - parent = new_repo.head.peel().oid + parent = new_repo.head.peel().id except pygit2.GitError: pass @@ -312,7 +312,7 @@ def _clean_git(repo, obj_repotype, obj_uid): # See if there is a parent to this commit parent = None if not new_repo.is_empty: - parent = new_repo.head.peel().oid + parent = new_repo.head.peel().id parents = [] if parent: @@ -909,7 +909,7 @@ def _add_file_to_git(repo, issue, attachmentfolder, user, filename): # See if there is a parent to this commit parent = None try: - parent = new_repo.head.peel().oid + parent = new_repo.head.peel().id except pygit2.GitError: pass @@ -1012,7 +1012,7 @@ class TemporaryClone(object): self.repo.branches.local.create(localname, branch.peel()) elif ref.startswith("refs/pull/"): reference = self._origrepo.references.get(ref) - self.repo.references.create(ref, reference.peel().oid.hex) + self.repo.references.create(ref, str(reference.peel().id)) return self @@ -1186,7 +1186,7 @@ def _update_file_in_git( parents = [] if parent: - parents.append(parent.hex) + parents.append(str(parent.id)) # Author/commiter will always be this one name = user.fullname or user.username @@ -1615,8 +1615,8 @@ def merge_pull_request(session, request, username, domerge=True): # Fetch the commits remote.fetch() - # repo_commit = fork_obj[branch.peel().hex] - repo_commit = new_repo[branch.peel().hex] + # repo_commit = fork_obj[str(branch.peel().id)] + repo_commit = new_repo[str(branch.peel().id)] # Checkout the correct branch if new_repo.is_empty or new_repo.head_is_unborn: @@ -1629,7 +1629,7 @@ def merge_pull_request(session, request, username, domerge=True): _log.info(" PR merged using fast-forward") if not request.project.settings.get("always_merge", False): new_repo.create_branch(request.branch, repo_commit) - commit = repo_commit.oid.hex + commit = str(repo_commit.id) else: tree = new_repo.index.write_tree() user_obj = pagure.lib.query.get_user(session, username) @@ -1643,7 +1643,7 @@ def merge_pull_request(session, request, username, domerge=True): author, "Merge #%s `%s`" % (request.id, request.title), tree, - [repo_commit.oid.hex], + [str(repo_commit.id)], ) _log.info(" New head: %s", commit) @@ -1674,14 +1674,14 @@ def merge_pull_request(session, request, username, domerge=True): ref = new_repo.lookup_reference( "refs/pull/%s/head" % request.id ) - repo_commit = new_repo[ref.target.hex] + repo_commit = new_repo[str(ref.target)] except KeyError: pass - merge = new_repo.merge(repo_commit.oid) + merge = new_repo.merge(repo_commit.id) _log.debug(" Merge: %s", merge) if merge is None: - mergecode = new_repo.merge_analysis(repo_commit.oid)[0] + mergecode = new_repo.merge_analysis(repo_commit.id)[0] _log.debug(" Mergecode: %s", mergecode) # Wait until the last minute then check if the PR was already closed @@ -1732,8 +1732,8 @@ def merge_pull_request(session, request, username, domerge=True): # This is depending on the pygit2 version branch_ref.target = merge.fastforward_oid elif merge is None and mergecode is not None: - branch_ref.set_target(repo_commit.oid.hex) - commit = repo_commit.oid.hex + branch_ref.set_target(str(repo_commit.id)) + commit = str(repo_commit.id) else: tree = new_repo.index.write_tree() user_obj = pagure.lib.query.get_user(session, username) @@ -1760,7 +1760,7 @@ def merge_pull_request(session, request, username, domerge=True): author, commit_message, tree, - [head.hex, repo_commit.oid.hex], + [str(head.id), str(repo_commit.id)], ) _log.info(" New head: %s", commit) @@ -1805,7 +1805,7 @@ def merge_pull_request(session, request, username, domerge=True): _log.info(" Writing down merge commit") head = new_repo.lookup_reference("HEAD").peel() _log.info( - " Basing on: %s - %s", head.hex, repo_commit.oid.hex + " Basing on: %s - %s", str(head.id), str(repo_commit.id) ) user_obj = pagure.lib.query.get_user(session, username) commitname = user_obj.fullname or user_obj.user @@ -1826,7 +1826,7 @@ def merge_pull_request(session, request, username, domerge=True): author, commit_message, tree, - [head.hex, repo_commit.oid.hex], + [str(head.id), str(repo_commit.id)], ) _log.info(" New head: %s", commit) @@ -2032,13 +2032,13 @@ def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): commitid = None if frombranch: - commitid = frombranch.peel().hex + commitid = str(frombranch.peel().id) elif prid is not None: # If there is not branch found but there is a PR open, use the ref # of that PR in the main repo try: ref = orig_repo.lookup_reference("refs/pull/%s/head" % prid) - commitid = ref.target.hex + commitid = str(ref.target) except KeyError: pass @@ -2060,14 +2060,14 @@ def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): "pagure.lib.git.get_diff_info: Pulling into a non-empty repo" ) if branch: - orig_commit = orig_repo[branch.peel().hex] + orig_commit = orig_repo[str(branch.peel().id)] main_walker = orig_repo.walk( - orig_commit.oid.hex, pygit2.GIT_SORT_NONE + str(orig_commit.id), pygit2.GIT_SORT_NONE ) repo_commit = repo_obj[commitid] branch_walker = repo_obj.walk( - repo_commit.oid.hex, pygit2.GIT_SORT_NONE + str(repo_commit.id), pygit2.GIT_SORT_NONE ) main_commits = set() @@ -2078,7 +2078,7 @@ def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): if branch: try: com = next(main_walker) - main_commits.add(com.oid.hex) + main_commits.add(str(com.id)) except StopIteration: com = None @@ -2092,7 +2092,7 @@ def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): break if branch_commit: - branch_commits.add(branch_commit.oid.hex) + branch_commits.add(str(branch_commit.id)) diff_commits.append(branch_commit) if main_commits.intersection(branch_commits): break @@ -2102,19 +2102,19 @@ def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): i = 0 if diff_commits and main_commits: for i in range(len(diff_commits)): - if diff_commits[i].oid.hex in main_commits: + if str(diff_commits[i].id) in main_commits: break diff_commits = diff_commits[:i] _log.debug("Diff commits: %s", diff_commits) if diff_commits: - first_commit = repo_obj[diff_commits[-1].oid.hex] + first_commit = repo_obj[str(diff_commits[-1].id)] if len(first_commit.parents) > 0: diff = repo_obj.diff( - repo_obj.revparse_single(first_commit.parents[0].oid.hex), - repo_obj.revparse_single(diff_commits[0].oid.hex), + repo_obj.revparse_single(str(first_commit.parents[0].id)), + repo_obj.revparse_single(str(diff_commits[0].id)), ) - elif first_commit.oid.hex == diff_commits[0].oid.hex: + elif str(first_commit.id) == str(diff_commits[0].id): _log.info( "pagure.lib.git.get_diff_info: First commit is also the " "last commit" @@ -2129,7 +2129,7 @@ def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): branch = repo_obj.lookup_branch(branch_from) repo_commit = branch.peel() - for commit in repo_obj.walk(repo_commit.oid.hex, pygit2.GIT_SORT_NONE): + for commit in repo_obj.walk(str(repo_commit.id), pygit2.GIT_SORT_NONE): diff_commits.append(commit) _log.debug("Diff commits: %s", diff_commits) @@ -2190,8 +2190,8 @@ def diff_pull_request( # Check if we can still rely on the merge_status commenttext = None if ( - request.commit_start != first_commit.oid.hex - or request.commit_stop != diff_commits[0].oid.hex + request.commit_start != str(first_commit.id) + or request.commit_stop != str(diff_commits[0].id) ): request.merge_status = None if request.commit_start: @@ -2199,7 +2199,7 @@ def diff_pull_request( new_commits_count = 0 commenttext = "" for i in diff_commits: - if i.oid.hex == request.commit_stop: + if str(i.id) == request.commit_stop: break new_commits_count = new_commits_count + 1 commenttext = "%s * ``%s``\n" % ( @@ -2218,15 +2218,15 @@ def diff_pull_request( ) if ( request.commit_start - and request.commit_start != first_commit.oid.hex + and request.commit_start != str(first_commit.id) ): pr_action = "rebased" if orig_commit: - commenttext = "rebased onto %s" % orig_commit.oid.hex + commenttext = "rebased onto %s" % str(orig_commit.id) else: commenttext = "rebased onto unknown target" - request.commit_start = first_commit.oid.hex - request.commit_stop = diff_commits[0].oid.hex + request.commit_start = str(first_commit.id) + request.commit_stop = str(diff_commits[0].id) session.add(request) session.commit() _log.debug( @@ -2335,7 +2335,7 @@ def get_git_tags(project, with_commits=False): if ref: com = ref.peel() if com: - tags[tag.split("refs/tags/")[1]] = com.oid.hex + tags[tag.split("refs/tags/")[1]] = str(com.id) else: tags = [ tag.split("refs/tags/")[1] @@ -2457,7 +2457,7 @@ def log_commits_to_db(session, project, commits, gitdir): user_email=commit.author.email if not author_obj else None, project_id=project.id, log_type="committed", - ref_id=commit.oid.hex, + ref_id=str(commit.id), date=date_created.date(), date_created=date_created.datetime, ) @@ -2500,7 +2500,7 @@ def get_git_branches(project, with_commits=False): resolved_branch = repo_obj.lookup_branch(branch).resolve() com = resolved_branch.peel() if com: - branches[branch] = com.oid.hex + branches[branch] = str(com.id) else: branches = repo_obj.listall_branches() @@ -2517,7 +2517,7 @@ def get_default_git_branches(project): branch = repo_obj.lookup_branch(branchname) commit = branch.peel(pygit2.Commit) - return branchname, commit.oid.hex + return branchname, str(commit.id) def new_git_branch( diff --git a/pagure/lib/tasks.py b/pagure/lib/tasks.py index 87ceea4..4163793 100644 --- a/pagure/lib/tasks.py +++ b/pagure/lib/tasks.py @@ -787,7 +787,7 @@ def commits_author_stats(self, session, repopath): authors_email = set() try: for commit in repo_obj.walk( - repo_obj.head.peel().oid.hex, pygit2.GIT_SORT_NONE + str(repo_obj.head.peel().id), pygit2.GIT_SORT_NONE ): # For each commit record how many times each combination of name and # e-mail appears in the git history. @@ -852,7 +852,7 @@ def commits_history_stats(self, session, repopath): try: for commit in repo_obj.walk( - repo_obj.head.peel().oid.hex, pygit2.GIT_SORT_NONE + str(repo_obj.head.peel().id), pygit2.GIT_SORT_NONE ): delta = ( datetime.datetime.utcnow() @@ -920,7 +920,7 @@ def link_pr_to_ticket(self, session, pr_uid): user = request.project.user.user if request.project.is_fork else None for line in pagure.lib.git.read_git_lines( - ["log", "--no-walk"] + [c.oid.hex for c in diff_commits] + ["--"], + ["log", "--no-walk"] + [str(c.id) for c in diff_commits] + ["--"], repopath, ): diff --git a/pagure/templates/commit.html b/pagure/templates/commit.html index 4238e0d..4883d17 100644 --- a/pagure/templates/commit.html +++ b/pagure/templates/commit.html @@ -69,12 +69,12 @@ 'ui_ns.view_tree', username=username, namespace=repo.namespace, repo=repo.name, identifier=commitid) }}">tree {% if commit.parents|length == 1 %} - parent + commitid=commit.parents[0].id.__str__()) }}">parent {% elif commit.parents|length > 1 %}
diff --git a/pagure/templates/commits.html b/pagure/templates/commits.html index 8aee5c9..a14f69c 100644 --- a/pagure/templates/commits.html +++ b/pagure/templates/commits.html @@ -107,7 +107,7 @@ repo=repo.name, username=username, namespace=repo.namespace, - commitid=diff_commit_full.hex) }}" + commitid=diff_commit_full.id.__str__()) }}" class="notblue"> {{ diff_commit_full.message.split('\n')[0] }} @@ -126,13 +126,13 @@ repo=repo.name, username=username, namespace=repo.namespace, - commitid=diff_commit_full.hex) }}" + commitid=diff_commit_full.id.__str__()) }}" class="btn btn-outline-primary font-weight-bold"> - {{ diff_commit_full.hex|short }} + {{ diff_commit_full.id.__str__()|short }} + repo=repo.name, identifier=diff_commit_full.id.__str__()) }}"> @@ -146,10 +146,10 @@ {% for commit in last_commits %} -
+
- {% if diff_commits and commit.oid.hex in diff_commits %} + {% if diff_commits and commit.id.__str__() in diff_commits %}
@@ -159,7 +159,7 @@ repo=repo.name, username=username, namespace=repo.namespace, - commitid=commit.hex, branch=branchname) }}" + commitid=commit.id.__str__(), branch=branchname) }}" class="notblue"> {{ commit.message.split('\n')[0] }} @@ -185,13 +185,13 @@ repo=repo.name, username=username, namespace=repo.namespace, - commitid=commit.hex, branch=branchname) }}" - class="btn btn-outline-primary font-weight-bold commithash" id="c_{{ commit.hex }}"> - {{ commit.hex|short }} + commitid=commit.id.__str__(), branch=branchname) }}" + class="btn btn-outline-primary font-weight-bold commithash" id="c_{{ commit.id.__str__() }}"> + {{ commit.id.__str__()|short }} + repo=repo.name, identifier=commit.id.__str__()) }}">
diff --git a/pagure/templates/file_history.html b/pagure/templates/file_history.html index d016528..994d780 100644 --- a/pagure/templates/file_history.html +++ b/pagure/templates/file_history.html @@ -101,14 +101,14 @@
{% for line in log %} {% set commit = g.repo_obj[line[0]] %} -
+
{{ commit.message.split('\n')[0] }} @@ -134,13 +134,13 @@ repo=repo.name, username=username, namespace=repo.namespace, - commitid=commit.hex, branch=branchname) }}" - class="btn btn-outline-primary font-weight-bold commithash" id="c_{{ commit.hex }}"> - {{ commit.hex|short }} + commitid=commit.id.__str__(), branch=branchname) }}" + class="btn btn-outline-primary font-weight-bold commithash" id="c_{{ commit.id.__str__() }}"> + {{ commit.id.__str__()|short }} + repo=repo.name, identifier=commit.id.__str__()) }}">
diff --git a/pagure/templates/releases.html b/pagure/templates/releases.html index 1ca3182..9a4bc4e 100644 --- a/pagure/templates/releases.html +++ b/pagure/templates/releases.html @@ -61,7 +61,7 @@ repo=repo.name, username=username, namespace=repo.namespace, - identifier=tag['object'].oid) }}" + identifier=tag['object'].id) }}" class="font-weight-bold"> {{tag['tagname']}} @@ -77,9 +77,9 @@ repo=repo.name, username=username, namespace=repo.namespace, - commitid=tag['object'].oid) }}" + commitid=tag['object'].id) }}" class="btn btn-outline-secondary disabled"> - {{ tag['object'].oid | short }} + {{ tag['object'].id | short }}
diff --git a/pagure/templates/repo_comparecommits.html b/pagure/templates/repo_comparecommits.html index 5c76efe..6f88a8f 100644 --- a/pagure/templates/repo_comparecommits.html +++ b/pagure/templates/repo_comparecommits.html @@ -50,10 +50,10 @@ repo=pull_request.project_from.name, username=pull_request.project_from.user.user, namespace=repo.namespace, - commitid=commit.oid.hex)%} + commitid=commit.id.__str__())%} {% set tree_link = url_for( 'ui_ns.view_tree', username=pull_request.project_from.user.user, namespace=repo.namespace, - repo=repo.name, identifier=commit.hex) %} + repo=repo.name, identifier=commit.id.__str__()) %} {% elif pull_request and pull_request.remote %} {% set commit_link = None %} {% else %} @@ -61,10 +61,10 @@ repo=repo.name, username=username, namespace=repo.namespace, - commitid=commit.oid.hex) %} + commitid=commit.id.__str__()) %} {% set tree_link = url_for( 'ui_ns.view_tree', username=username, namespace=repo.namespace, - repo=repo.name, identifier=commit.hex) %} + repo=repo.name, identifier=commit.id.__str__()) %} {% endif %} {% if not loop.last and loop.index == 2 %}
@@ -104,7 +104,7 @@ diff --git a/pagure/templates/repo_info.html b/pagure/templates/repo_info.html index e8ec2e0..b26c0e3 100644 --- a/pagure/templates/repo_info.html +++ b/pagure/templates/repo_info.html @@ -277,10 +277,10 @@ repo=repo.name, username=username, namespace=repo.namespace, - commitid=commit.hex, branch=branchname) }}" + commitid=commit.id.__str__(), branch=branchname) }}" class="notblue"> {{ branchname }}{{ commit.hex|short }} + class="py-1 px-2 font-weight-bold commit_hash">{{ commit.id.__str__()|short }} {{ commit.message.split('\n')[0] }}
diff --git a/pagure/templates/repo_new_pull_request.html b/pagure/templates/repo_new_pull_request.html index bec836b..921bb17 100644 --- a/pagure/templates/repo_new_pull_request.html +++ b/pagure/templates/repo_new_pull_request.html @@ -265,10 +265,10 @@ repo=repo.name, username=username, namespace=repo.namespace, - commitid=commit.oid.hex) %} + commitid=commit.id.__str__()) %} {% set tree_link = url_for( 'ui_ns.view_tree', username=username, namespace=repo.namespace, - repo=repo.name, identifier=commit.hex) %} + repo=repo.name, identifier=commit.id.__str__()) %}
@@ -299,7 +299,7 @@ diff --git a/pagure/templates/repo_pull_request.html b/pagure/templates/repo_pull_request.html index fd7d9d2..1b9c226 100644 --- a/pagure/templates/repo_pull_request.html +++ b/pagure/templates/repo_pull_request.html @@ -304,10 +304,10 @@ repo=pull_request.project_from.name, username=pull_request.project_from.user.user, namespace=repo.namespace, - commitid=commit.oid.hex)%} + commitid=commit.id.__str__())%} {% set tree_link = url_for( 'ui_ns.view_tree', username=pull_request.project_from.user.user, namespace=repo.namespace, - repo=repo.name, identifier=commit.hex) %} + repo=repo.name, identifier=commit.id.__str__()) %} {% elif pull_request.remote %} {% set commit_link = None %} {% else %} @@ -315,12 +315,12 @@ repo=repo.name, username=repo.user.user if repo.is_fork else None, namespace=repo.namespace, - commitid=commit.oid.hex) %} + commitid=commit.id.__str__()) %} {% set tree_link = url_for( 'ui_ns.view_tree', username=repo.user.user if repo.is_fork else None, namespace=repo.namespace, - repo=repo.name, identifier=commit.hex) %} + repo=repo.name, identifier=commit.id.__str__()) %} {% endif %}
@@ -350,9 +350,9 @@
diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index 4786d3a..45f0948 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -149,7 +149,7 @@ def format_loc( commit_hash = commit if hasattr(commit_hash, "hex"): - commit_hash = commit_hash.hex + commit_hash = str(commit_hash.id) comments = {} if prequest and not isinstance(prequest, flask.wrappers.Request): diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index 01556e1..64aa79d 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -279,7 +279,7 @@ def request_pull(repo, requestid, username=None, namespace=None): try: for commit in repo_obj.walk(commitid, pygit2.GIT_SORT_NONE): diff_commits.append(commit) - if commit.oid.hex == request.commit_start: + if str(commit.id) == request.commit_start: break except KeyError: # This happens when repo.walk() cannot find commitid @@ -288,19 +288,19 @@ def request_pull(repo, requestid, username=None, namespace=None): if diff_commits: # Ensure the first commit in the PR as a parent, otherwise # point to it - start = diff_commits[-1].oid.hex + start = str(diff_commits[-1].id) if diff_commits[-1].parents: - start = diff_commits[-1].parents[0].oid.hex + start = str(diff_commits[-1].parents[0].id) # If the start and the end commits are the same, it means we are, # dealing with one commit that has no parent, so just diff that # one commit - if start == diff_commits[0].oid.hex: + if start == str(diff_commits[0].id): diff = diff_commits[0].tree.diff_to_tree(swap=True) else: diff = repo_obj.diff( repo_obj.revparse_single(start), - repo_obj.revparse_single(diff_commits[0].oid.hex), + repo_obj.revparse_single(str(diff_commits[0].id)), ) else: try: @@ -454,7 +454,7 @@ def request_pull_to_diff_or_patch( branch = repo_obj.lookup_branch(request.branch_from) commitid = None if branch: - commitid = branch.peel().hex + commitid = str(branch.peel().id) diff_commits = [] if request.status != "Open": @@ -462,7 +462,7 @@ def request_pull_to_diff_or_patch( try: for commit in repo_obj.walk(commitid, pygit2.GIT_SORT_NONE): diff_commits.append(commit) - if commit.oid.hex == request.commit_start: + if str(commit.id) == request.commit_start: break except KeyError: # This happens when repo.walk() cannot find commitid @@ -1726,7 +1726,7 @@ def new_request_pull( ) if orig_commit: - orig_commit = orig_commit.oid.hex + orig_commit = str(orig_commit.id) initial_comment = ( form.initial_comment.data.strip() @@ -1735,8 +1735,8 @@ def new_request_pull( ) commit_start = commit_stop = None if diff_commits: - commit_stop = diff_commits[0].oid.hex - commit_start = diff_commits[-1].oid.hex + commit_stop = str(diff_commits[0].id) + commit_start = str(diff_commits[-1].id) request = pagure.lib.query.new_pull_request( flask.g.session, repo_to=parent, @@ -1967,7 +1967,7 @@ def new_remote_request_pull(repo, username=None, namespace=None): ) if orig_commit: - orig_commit = orig_commit.oid.hex + orig_commit = str(orig_commit.id) parent = repo if repo.parent: diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index 26efbe2..fad6266 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -1508,7 +1508,7 @@ def view_issue_raw_file(repo, filename=None, username=None, namespace=None): if not content or isinstance(content, pygit2.Tree): flask.abort(404, description="File not found") - data = repo_obj[content.oid].data + data = repo_obj[content.id].data if not data: flask.abort(404, description="No content found") diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 8d8d26a..8dde5c6 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -209,7 +209,7 @@ def view_repo_branch(repo, branchname, username=None, namespace=None): head = None cnt = 0 last_commits = [] - for commit in repo_obj.walk(branch.peel().hex, pygit2.GIT_SORT_NONE): + for commit in repo_obj.walk(str(branch.peel().id), pygit2.GIT_SORT_NONE): last_commits.append(commit) cnt += 1 if cnt == 3: @@ -238,19 +238,19 @@ def view_repo_branch(repo, branchname, username=None, namespace=None): if compare_branch: commit_list = [ - commit.oid.hex + str(commit.id) for commit in orig_repo.walk( - compare_branch.peel().hex, + str(compare_branch.peel().id), pygit2.GIT_SORT_NONE) ] - repo_commit = repo_obj[branch.peel().hex] + repo_commit = repo_obj[str(branch.peel().id)] for commit in repo_obj.walk( - repo_commit.oid.hex, pygit2.GIT_SORT_NONE): - if commit.oid.hex in commit_list: + str(repo_commit.id), pygit2.GIT_SORT_NONE): + if str(commit.id) in commit_list: break - diff_commits.append(commit.oid.hex) + diff_commits.append(str(commit.id)) tree = sorted(last_commits[0].tree, key=lambda x: x.filemode) for i in tree: @@ -319,11 +319,11 @@ def view_commits(repo, branchname=None, username=None, namespace=None): # where we expected a commit, in this case, get the actual commit if isinstance(commit, pygit2.Tag): commit = commit.peel(pygit2.Commit) - branchname = commit.oid.hex + branchname = str(commit.id) elif isinstance(commit, pygit2.Blob): try: commit = commit.peel(pygit2.Commit) - branchname = commit.oid.hex + branchname = str(commit.id) except Exception: flask.abort( 404, description="Invalid branch/identifier provided" @@ -360,7 +360,7 @@ def view_commits(repo, branchname=None, username=None, namespace=None): n_commits = 0 last_commits = [] if commit: - for commit in repo_obj.walk(commit.hex, pygit2.GIT_SORT_NONE): + for commit in repo_obj.walk(str(commit.id), pygit2.GIT_SORT_NONE): # Filters the commits for a user if author_obj: @@ -411,7 +411,7 @@ def view_commits(repo, branchname=None, username=None, namespace=None): ) for commit in diff_commits_full: - diff_commits.append(commit.oid.hex) + diff_commits.append(str(commit.id)) return flask.render_template( "commits.html", @@ -467,7 +467,7 @@ def compare_commits(repo, commit1, commit2, username=None, namespace=None): last_commit = commit2 commits = [ - commit.oid.hex[: len(first_commit)] + str(commit.id)[: len(first_commit)] for commit in repo_obj.walk(last_commit, pygit2.GIT_SORT_NONE) ] @@ -478,7 +478,7 @@ def compare_commits(repo, commit1, commit2, username=None, namespace=None): for commit in repo_obj.walk(last_commit, order): diff_commits.append(commit) - if commit.oid.hex == first_commit or commit.oid.hex.startswith( + if str(commit.id) == first_commit or str(commit.id).startswith( first_commit ): break @@ -547,7 +547,7 @@ def view_file(repo, identifier, filename, username=None, namespace=None): ) if not content: flask.abort(404, description="File not found") - content = repo_obj[content.oid] + content = repo_obj[content.id] else: content = commit @@ -712,7 +712,7 @@ def view_raw_file( if not content or isinstance(content, pygit2.Tree): flask.abort(404, description="File not found") - data = repo_obj[content.oid].data + data = repo_obj[content.id].data else: if commit.parents: # We need to take this not so nice road to ensure that the @@ -799,7 +799,7 @@ def view_blame_file(repo, filename, username=None, namespace=None): _log.exception("File could not be decoded") flask.abort(500, description="File could not be decoded") - blame = repo_obj.blame(filename, newest_commit=commit.oid.hex) + blame = repo_obj.blame(filename, newest_commit=str(commit.id)) return flask.render_template( "blame.html", @@ -911,7 +911,7 @@ def view_commit(repo, commitid, username=None, namespace=None): repo=repo.name, username=username, namespace=repo.namespace, - commitid=commit.hex, + commitid=str(commit.id), ) ) @@ -1057,7 +1057,7 @@ def view_tree(repo, identifier=None, username=None, namespace=None): # where we expected a commit, in this case, get the actual commit if isinstance(commit, pygit2.Tag): commit = commit.peel(pygit2.Commit) - branchname = commit.oid.hex + branchname = str(commit.id) if commit and not isinstance(commit, pygit2.Blob): content = sorted(commit.tree, key=lambda x: x.filemode) @@ -2596,7 +2596,7 @@ def edit_file(repo, branchname, filename, username=None, namespace=None): flask.abort(400, description="Cannot edit binary files") try: - data = repo_obj[content.oid].data.decode("utf-8") + data = repo_obj[content.id].data.decode("utf-8") except UnicodeDecodeError: # pragma: no cover # In theory we shouldn't reach here since we check if the file # is binary with `is_binary_string()` above @@ -3540,7 +3540,7 @@ def generate_project_archive( archive_folder, flask.g.repo.fullname, tag_path, - commit.oid.hex, + str(commit.id), "%s.%s" % (name, extension), ) headers = { @@ -3563,7 +3563,7 @@ def generate_project_archive( repo, namespace=namespace, username=username, - commit=commit.oid.hex, + commit=str(commit.id), tag=tag_filename, name=name, archive_fmt=extension, diff --git a/pagure/utils.py b/pagure/utils.py index 33a6e0b..7e8c507 100644 --- a/pagure/utils.py +++ b/pagure/utils.py @@ -433,12 +433,12 @@ def __get_file_in_tree(repo_obj, tree, filepath, bail_on_tree=False): pass else: if dereferenced.filemode == pygit2.GIT_FILEMODE_BLOB: - blob = repo_obj[dereferenced.oid] + blob = repo_obj[dereferenced.id] return blob else: try: - nextitem = repo_obj[entry.oid] + nextitem = repo_obj[entry.id] except KeyError: # We could not find the blob/entry in the git repo # so we bail diff --git a/tests/__init__.py b/tests/__init__.py index 24fd97e..3c71a9b 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -757,13 +757,13 @@ def _clone_and_top_commits(folder, branch, branch_ref=False): commit = None try: if branch_ref_obj: - commit = repo[branch_ref_obj.peel().hex] + commit = repo[str(branch_ref_obj.peel().id)] else: commit = repo.revparse_single("HEAD") except KeyError: pass if commit: - parents = [commit.oid.hex] + parents = [str(commit.id)] return (repo, newfolder, parents) @@ -802,7 +802,7 @@ def add_content_git_repo( ) if commit: - parents = [commit.hex] + parents = [str(commit)] subfolder = os.path.join("folder1", "folder2") if not os.path.exists(os.path.join(newfolder, subfolder)): @@ -833,7 +833,7 @@ def add_content_git_repo( if extra_commit: if commit: - parents = [commit.hex] + parents = [str(commit.id)] # Create another file in that git repo with open(os.path.join(newfolder, "test"), "w") as stream: @@ -954,13 +954,13 @@ def add_commit_git_repo( commit = None try: if branch_ref_obj: - commit = repo[branch_ref_obj.peel().hex] + commit = repo[str(branch_ref_obj.peel().id)] else: commit = repo.revparse_single("HEAD") except (KeyError, AttributeError): pass if commit: - parents = [commit.oid.hex] + parents = [str(commit.id)] # Commits the files added tree = repo.index.write_tree() @@ -1041,13 +1041,13 @@ def add_content_to_git( commit = None try: if branch_ref_obj: - commit = repo[branch_ref_obj.peel().hex] + commit = repo[str(branch_ref_obj.peel().id)] else: commit = repo.revparse_single("HEAD") except (KeyError, AttributeError): pass if commit: - parents = [commit.oid.hex] + parents = [str(commit.id)] # Commits the files added tree = repo.index.write_tree() @@ -1222,7 +1222,7 @@ def add_pull_request_git_repo( committer, "A commit on branch %s" % branch_from, tree, - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/%s" % (branch_from) ori_remote = clone_repo.remotes[0] diff --git a/tests/test_pagure_flask_api_project.py b/tests/test_pagure_flask_api_project.py index 47e6026..e692db9 100644 --- a/tests/test_pagure_flask_api_project.py +++ b/tests/test_pagure_flask_api_project.py @@ -87,7 +87,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0) repo.create_tag( "0.0.1", - first_commit.oid.hex, + str(first_commit.id), pygit2.GIT_OBJ_COMMIT, tagger, "Release 0.0.1", @@ -2614,7 +2614,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): tests.create_tokens(self.session, project_id=None) tests.create_tokens_acl(self.session, "aaabbbcccddd", "create_branch") repo_obj = pygit2.Repository(git_path) - from_commit = repo_obj.revparse_single("HEAD").oid.hex + from_commit = str(repo_obj.revparse_single("HEAD").id) headers = {"Authorization": "token aaabbbcccddd"} args = {"branch": "test123", "from_commit": from_commit} output = self.app.post( @@ -2655,7 +2655,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): "uid": "jenkins_build_pagure_100+seed", } output = self.app.post( - "/api/0/test/c/%s/flag" % commit.oid.hex, + "/api/0/test/c/%s/flag" % str(commit.id), headers=headers, data=data, ) @@ -2684,7 +2684,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): "status": "success", } output = self.app.post( - "/api/0/test/c/%s/flag" % commit.oid.hex, + "/api/0/test/c/%s/flag" % str(commit.id), headers=headers, data=data, ) @@ -2711,7 +2711,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): "status": "success", } output = self.app.post( - "/api/0/test/c/%s/flag" % commit.oid.hex, + "/api/0/test/c/%s/flag" % str(commit.id), headers=headers, data=data, ) @@ -2738,7 +2738,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): "status": "success", } output = self.app.post( - "/api/0/test/c/%s/flag" % commit.oid.hex, + "/api/0/test/c/%s/flag" % str(commit.id), headers=headers, data=data, ) @@ -2765,7 +2765,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): "uid": "jenkins_build_pagure_100+seed", } output = self.app.post( - "/api/0/test/c/%s/flag" % commit.oid.hex, + "/api/0/test/c/%s/flag" % str(commit.id), headers=headers, data=data, ) @@ -2794,7 +2794,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): "status": "foobar", } output = self.app.post( - "/api/0/test/c/%s/flag" % commit.oid.hex, + "/api/0/test/c/%s/flag" % str(commit.id), headers=headers, data=data, ) @@ -2824,7 +2824,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): "status": "success", } output = self.app.post( - "/api/0/test/c/%s/flag" % commit.oid.hex, + "/api/0/test/c/%s/flag" % str(commit.id), headers=headers, data=data, ) @@ -2921,7 +2921,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): "milestones": {}, }, "flag": { - "commit_hash": commit.oid.hex, + "commit_hash": str(commit.id), "username": "Jenkins", "percent": "0", "comment": "Tests running", @@ -2941,7 +2941,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): ) ): output = self.app.post( - "/api/0/test/c/%s/flag" % commit.oid.hex, + "/api/0/test/c/%s/flag" % str(commit.id), headers=headers, data=data, ) @@ -2952,7 +2952,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): expected_output = { "flag": { "comment": "Tests running", - "commit_hash": commit.oid.hex, + "commit_hash": str(commit.id), "date_created": "1510742565", "date_updated": "1510742565", "percent": 0, @@ -3028,7 +3028,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): "milestones": {}, }, "flag": { - "commit_hash": commit.oid.hex, + "commit_hash": str(commit.id), "username": "Jenkins", "percent": "100", "comment": "Tests passed", @@ -3048,7 +3048,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): ) ): output = self.app.post( - "/api/0/test/c/%s/flag" % commit.oid.hex, + "/api/0/test/c/%s/flag" % str(commit.id), headers=headers, data=data, ) @@ -3059,7 +3059,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): expected_output = { "flag": { "comment": "Tests passed", - "commit_hash": commit.oid.hex, + "commit_hash": str(commit.id), "date_created": "1510742565", "date_updated": "1510742565", "percent": 100, @@ -3099,7 +3099,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): "status": "success", } output = self.app.post( - "/api/0/test/c/%s/flag" % commit.oid.hex, + "/api/0/test/c/%s/flag" % str(commit.id), headers=headers, data=data, ) @@ -3112,7 +3112,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): expected_output = { "flag": { "comment": "Tests passed", - "commit_hash": commit.oid.hex, + "commit_hash": str(commit.id), "date_created": "1510742565", "date_updated": "1510742565", "percent": 100, @@ -3160,7 +3160,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): } output = self.app.post( - "/api/0/test/c/%s/flag" % commit.oid.hex, + "/api/0/test/c/%s/flag" % str(commit.id), headers=headers, data=data, ) @@ -3173,7 +3173,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): expected_output = { "flag": { "comment": "Tests passed", - "commit_hash": commit.oid.hex, + "commit_hash": str(commit.id), "date_created": "1510742565", "date_updated": "1510742565", "percent": 100, @@ -3196,10 +3196,10 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): mock_email.assert_called_once_with( "\nJenkins flagged the commit " - "`" + commit.oid.hex + "` as success: " + "`" + str(commit.id) + "` as success: " "Tests passed\n\n" - "http://localhost.localdomain/test/c/" + commit.oid.hex + "\n", - "Commit #" + commit.oid.hex + " - Jenkins: success", + "http://localhost.localdomain/test/c/" + str(commit.id) + "\n", + "Commit #" + str(commit.id) + " - Jenkins: success", "bar@pingou.com", in_reply_to="test-project-1", mail_id="test-commit-1-1", @@ -3235,7 +3235,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): "status": "succeed!", } output = self.app.post( - "/api/0/test/c/%s/flag" % commit.oid.hex, + "/api/0/test/c/%s/flag" % str(commit.id), headers=headers, data=send_data, ) @@ -3246,7 +3246,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): # Try invalid flag status send_data["status"] = "nooooo...." output = self.app.post( - "/api/0/test/c/%s/flag" % commit.oid.hex, + "/api/0/test/c/%s/flag" % str(commit.id), headers=headers, data=send_data, ) @@ -3268,7 +3268,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): commit = repo_obj.revparse_single("HEAD") # test with no flags - output = self.app.get("/api/0/test/c/%s/flag" % commit.oid.hex) + output = self.app.get("/api/0/test/c/%s/flag" % str(commit.id)) self.assertEqual( json.loads(output.get_data(as_text=True)), {"total_flags": 0, "flags": []}, @@ -3279,7 +3279,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): pagure.lib.query.add_commit_flag( session=self.session, repo=repo, - commit_hash=commit.oid.hex, + commit_hash=str(commit.id), username="simple-koji-ci", status="pending", percent=None, @@ -3293,7 +3293,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): pagure.lib.query.add_commit_flag( session=self.session, repo=repo, - commit_hash=commit.oid.hex, + commit_hash=str(commit.id), username="complex-koji-ci", status="success", percent=None, @@ -3305,7 +3305,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): ) self.session.commit() - output = self.app.get("/api/0/test/c/%s/flag" % commit.oid.hex) + output = self.app.get("/api/0/test/c/%s/flag" % str(commit.id)) data = json.loads(output.get_data(as_text=True)) for f in data["flags"]: @@ -4893,7 +4893,7 @@ class PagureFlaskApiProjectCommitInfotests(tests.Modeltests): def test_api_commit_info(self): """Test flagging a commit with missing precentage.""" - output = self.app.get("/api/0/test/c/%s/info" % self.commit.oid.hex) + output = self.app.get("/api/0/test/c/%s/info" % str(self.commit.id)) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) expected_output = { @@ -4901,10 +4901,10 @@ class PagureFlaskApiProjectCommitInfotests(tests.Modeltests): "commit_time": self.commit.commit_time, "commit_time_offset": self.commit.commit_time_offset, "committer": "Cecil Committer", - "hash": self.commit.oid.hex, + "hash": str(self.commit.id), "message": "Add some directory and a file for more testing", - "parent_ids": [self.commit.parent_ids[0].hex], - "tree_id": self.commit.tree_id.hex, + "parent_ids": [str(self.commit.parent_ids[0].id)], + "tree_id": str(self.commit.tree_id), } self.assertEqual(data, expected_output) @@ -4923,7 +4923,7 @@ class PagureFlaskApiProjectCommitInfotests(tests.Modeltests): def test_api_commit_info_hash_tree(self): """Test flagging a commit with missing username.""" output = self.app.get( - "/api/0/test/c/%s/info" % self.commit.tree_id.hex + "/api/0/test/c/%s/info" % str(self.commit.tree_id) ) self.assertEqual(output.status_code, 404) @@ -4994,12 +4994,12 @@ class PagureFlaskApiProjectGitBranchestests(tests.Modeltests): data, { "branches": { - "master": self.commit.hex, - "pats-win-49": self.commit.hex, - "pats-win-51": self.commit.hex, + "master": str(self.commit.id), + "pats-win-49": str(self.commit.id), + "pats-win-51": str(self.commit.id), }, "default": { - "master": self.commit.hex, + "master": str(self.commit.id), }, "total_branches": 3, }, @@ -5048,12 +5048,12 @@ class PagureFlaskApiProjectGitBranchestests(tests.Modeltests): data, { "branches": { - "master": self.commit.hex, - "pats-win-49": self.commit.hex, - "pats-win-51": self.commit.hex, + "master": str(self.commit.id), + "pats-win-49": str(self.commit.id), + "pats-win-51": str(self.commit.id), }, "default": { - "pats-win-49": self.commit.hex, + "pats-win-49": str(self.commit.id), }, "total_branches": 3, }, @@ -5074,12 +5074,12 @@ class PagureFlaskApiProjectGitBranchestests(tests.Modeltests): data, { "branches": { - "master": self.commit.hex, - "pats-win-49": self.commit.hex, - "pats-win-51": self.commit.hex, + "master": str(self.commit.id), + "pats-win-49": str(self.commit.id), + "pats-win-51": str(self.commit.id), }, "default": { - "pats-win-49": self.commit.hex, + "pats-win-49": str(self.commit.id), }, "total_branches": 3, }, diff --git a/tests/test_pagure_flask_api_project_git_tags.py b/tests/test_pagure_flask_api_project_git_tags.py index b7c3a17..7619489 100644 --- a/tests/test_pagure_flask_api_project_git_tags.py +++ b/tests/test_pagure_flask_api_project_git_tags.py @@ -87,7 +87,7 @@ class PagureFlaskApiProjectGitTagstests(tests.Modeltests): latest_commit = repo.revparse_single("HEAD") data = { "tagname": "test-tag-no-message", - "commit_hash": latest_commit.oid.hex, + "commit_hash": str(latest_commit.id), "message": None, } @@ -108,7 +108,7 @@ class PagureFlaskApiProjectGitTagstests(tests.Modeltests): data = json.loads(output.get_data(as_text=True)) self.assertEqual(sorted(data.keys()), ["tags", "total_tags"]) self.assertEqual( - data["tags"], {"test-tag-no-message": latest_commit.oid.hex} + data["tags"], {"test-tag-no-message": str(latest_commit.id)} ) self.assertEqual(data["total_tags"], 1) @@ -128,7 +128,7 @@ class PagureFlaskApiProjectGitTagstests(tests.Modeltests): latest_commit = repo.revparse_single("HEAD") data = { "tagname": "test-tag-no-message", - "commit_hash": latest_commit.oid.hex, + "commit_hash": str(latest_commit.id), "message": None, "with_commits": True, } @@ -142,7 +142,7 @@ class PagureFlaskApiProjectGitTagstests(tests.Modeltests): sorted(data.keys()), ["tag_created", "tags", "total_tags"] ) self.assertEqual( - data["tags"], {"test-tag-no-message": latest_commit.oid.hex} + data["tags"], {"test-tag-no-message": str(latest_commit.id)} ) self.assertEqual(data["total_tags"], 1) self.assertEqual(data["tag_created"], True) @@ -163,7 +163,7 @@ class PagureFlaskApiProjectGitTagstests(tests.Modeltests): latest_commit = repo.revparse_single("HEAD") data = { "tagname": "test-tag-no-message", - "commit_hash": latest_commit.oid.hex, + "commit_hash": str(latest_commit.id), "message": "This is a long annotation\nover multiple lines\n for testing", } @@ -195,7 +195,7 @@ class PagureFlaskApiProjectGitTagstests(tests.Modeltests): latest_commit = repo.revparse_single("HEAD") data = { "tagname": "test-tag-no-message", - "commit_hash": latest_commit.oid.hex, + "commit_hash": str(latest_commit.id), "message": "This is a long annotation\nover multiple lines\n for testing", } @@ -214,7 +214,7 @@ class PagureFlaskApiProjectGitTagstests(tests.Modeltests): # Submit the same request/tag a second time to the same commit data = { "tagname": "test-tag-no-message", - "commit_hash": latest_commit.oid.hex, + "commit_hash": str(latest_commit.id), "message": "This is a long annotation\nover multiple lines\n for testing", } @@ -253,7 +253,7 @@ class PagureFlaskApiProjectGitTagstests(tests.Modeltests): latest_commit = repo.revparse_single("HEAD") data = { "tagname": "test-tag-no-message", - "commit_hash": latest_commit.oid.hex, + "commit_hash": str(latest_commit.id), "message": "This is a long annotation\nover multiple lines\n for testing", } @@ -291,7 +291,7 @@ class PagureFlaskApiProjectGitTagstests(tests.Modeltests): latest_commit = repo.revparse_single("HEAD") data = { "tagname": "test-tag-no-message", - "commit_hash": latest_commit.oid.hex, + "commit_hash": str(latest_commit.id), "message": "This is a long annotation\nover multiple lines\n for testing", } @@ -321,7 +321,7 @@ class PagureFlaskApiProjectGitTagstests(tests.Modeltests): # Add a tag so that we can list it repo = pygit2.Repository(os.path.join(self.path, "repos", "test.git")) latest_commit = repo.revparse_single("HEAD") - prev_commit = latest_commit.parents[0].oid.hex + prev_commit = str(latest_commit.parents[0].id) data = { "tagname": "test-tag-no-message", "commit_hash": prev_commit, @@ -344,7 +344,7 @@ class PagureFlaskApiProjectGitTagstests(tests.Modeltests): # Submit the same request/tag a second time to the same commit data = { "tagname": "test-tag-no-message", - "commit_hash": latest_commit.oid.hex, + "commit_hash": str(latest_commit.id), "message": "This is a long annotation\nover multiple lines\n for testing", "with_commits": True, "force": True, @@ -359,7 +359,7 @@ class PagureFlaskApiProjectGitTagstests(tests.Modeltests): sorted(data.keys()), ["tag_created", "tags", "total_tags"] ) self.assertEqual( - data["tags"], {"test-tag-no-message": latest_commit.oid.hex} + data["tags"], {"test-tag-no-message": str(latest_commit.id)} ) self.assertEqual(data["total_tags"], 1) self.assertEqual(data["tag_created"], True) diff --git a/tests/test_pagure_flask_api_project_view_file.py b/tests/test_pagure_flask_api_project_view_file.py index a05e16f..2d000dc 100644 --- a/tests/test_pagure_flask_api_project_view_file.py +++ b/tests/test_pagure_flask_api_project_view_file.py @@ -242,7 +242,7 @@ class PagureFlaskApiProjectViewFiletests(tests.Modeltests): repo = pygit2.Repository(os.path.join(self.path, "repos", "test.git")) commit = repo.revparse_single("HEAD") - output = self.app.get("/api/0/test/tree/%s" % commit.oid.hex) + output = self.app.get("/api/0/test/tree/%s" % str(commit.id)) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( @@ -251,7 +251,7 @@ class PagureFlaskApiProjectViewFiletests(tests.Modeltests): "content": [ { "content_url": "http://localhost/test/raw/" - "%s/f/README.rst" % commit.oid.hex, + "%s/f/README.rst" % str(commit.id), "name": "README.rst", "path": "README.rst", "type": "file", @@ -270,7 +270,7 @@ class PagureFlaskApiProjectViewFiletests(tests.Modeltests): commit = repo.revparse_single("HEAD") output = self.app.get( - "/api/0/test/tree/%s/f/folder1" % commit.tree.oid.hex + "/api/0/test/tree/%s/f/folder1" % str(commit.tree.id) ) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) @@ -280,7 +280,7 @@ class PagureFlaskApiProjectViewFiletests(tests.Modeltests): "content": [ { "content_url": "http://localhost/api/0/test/tree/" - "%s/f/folder1/folder2" % commit.tree.oid.hex, + "%s/f/folder1/folder2" % str(commit.tree.id), "name": "folder2", "path": "folder1/folder2", "type": "folder", @@ -297,13 +297,13 @@ class PagureFlaskApiProjectViewFiletests(tests.Modeltests): tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0) tag = repo.create_tag( "v1.0_tag", - commit.oid.hex, + str(commit.id), pygit2.GIT_OBJ_COMMIT, tagger, "Release v1.0", ) - output = self.app.get("/api/0/test/tree/%s" % tag.hex) + output = self.app.get("/api/0/test/tree/%s" % str(tag)) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( @@ -312,7 +312,7 @@ class PagureFlaskApiProjectViewFiletests(tests.Modeltests): "content": [ { "content_url": "http://localhost/test/raw/" - "%s/f/README.rst" % tag.hex, + "%s/f/README.rst" % str(tag), "name": "README.rst", "path": "README.rst", "type": "file", diff --git a/tests/test_pagure_flask_api_ui_private_repo.py b/tests/test_pagure_flask_api_ui_private_repo.py index fb652f7..aa45da8 100644 --- a/tests/test_pagure_flask_api_ui_private_repo.py +++ b/tests/test_pagure_flask_api_ui_private_repo.py @@ -324,7 +324,7 @@ class PagurePrivateRepotest(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/master:refs/heads/master" ori_remote = clone_repo.remotes[0] @@ -350,7 +350,7 @@ class PagurePrivateRepotest(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/master:refs/heads/master" ori_remote = clone_repo.remotes[0] @@ -387,7 +387,7 @@ class PagurePrivateRepotest(tests.Modeltests): committer, "A commit on branch %s" % branch_from, tree, - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/%s" % (branch_from) ori_remote = repo.remotes[0] @@ -1232,7 +1232,7 @@ class PagurePrivateRepotest(tests.Modeltests): tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0) repo.create_tag( "0.0.1", - first_commit.oid.hex, + str(first_commit.id), pygit2.GIT_OBJ_COMMIT, tagger, "Release 0.0.1", diff --git a/tests/test_pagure_flask_internal.py b/tests/test_pagure_flask_internal.py index 0359459..ad3d126 100644 --- a/tests/test_pagure_flask_internal.py +++ b/tests/test_pagure_flask_internal.py @@ -481,7 +481,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) second_commit = repo.revparse_single("HEAD") @@ -602,7 +602,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) second_commit = repo.revparse_single("HEAD") @@ -726,7 +726,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/feature:refs/heads/feature" ori_remote = repo.remotes[0] @@ -750,7 +750,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/master:refs/heads/master" ori_remote = repo.remotes[0] @@ -891,7 +891,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/feature:refs/heads/feature" ori_remote = repo.remotes[0] @@ -915,7 +915,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/master:refs/heads/master" ori_remote = repo.remotes[0] @@ -1040,7 +1040,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/feature:refs/heads/feature" ori_remote = repo.remotes[0] @@ -1064,7 +1064,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/master:refs/heads/master" ori_remote = repo.remotes[0] @@ -1200,7 +1200,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/feature:refs/heads/feature" ori_remote = repo.remotes[0] @@ -1342,7 +1342,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/feature:refs/heads/feature" ori_remote = repo.remotes[0] @@ -1366,7 +1366,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/master:refs/heads/master" ori_remote = repo.remotes[0] @@ -1477,7 +1477,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/feature:refs/heads/feature" ori_remote = repo.remotes[0] @@ -1501,7 +1501,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/master:refs/heads/master" ori_remote = repo.remotes[0] @@ -1669,7 +1669,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) # Create another file in the master branch @@ -1690,7 +1690,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) # All good but the commit id @@ -1777,7 +1777,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # list of binary strings representing parents of the new commit [], ) - commit_hash = commit.hex + commit_hash = str(commit) # All good data = { @@ -1905,7 +1905,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) # Create another file in the master branch @@ -1926,7 +1926,7 @@ class PagureFlaskInternaltests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) # All good diff --git a/tests/test_pagure_flask_rebase.py b/tests/test_pagure_flask_rebase.py index 307ddb5..0dca513 100644 --- a/tests/test_pagure_flask_rebase.py +++ b/tests/test_pagure_flask_rebase.py @@ -253,7 +253,7 @@ class PagureRebasetests(PagureRebaseBasetests): orig_repo_obj = pygit2.Repository( os.path.join(self.path, "repos", "test.git") ) - orig_commit = orig_repo_obj.lookup_branch("master").peel().hex + orig_commit = str(orig_repo_obj.lookup_branch("master").peel().id) expected = f'rebased onto

Cf commit {1}' "

".format( - first_commit.oid.hex, first_commit.oid.hex[:7] + str(first_commit.id), str(first_commit.id)[:7] ) ) diff --git a/tests/test_pagure_flask_ui_archives.py b/tests/test_pagure_flask_ui_archives.py index 1da3d31..4e9937c 100644 --- a/tests/test_pagure_flask_ui_archives.py +++ b/tests/test_pagure_flask_ui_archives.py @@ -152,7 +152,7 @@ class PagureFlaskUiArchivesTest(tests.Modeltests): symlink_to=symlinkdir_target, ) tests.add_readme_git_repo(repopath) - commit = repo.head.target.hex + commit = str(repo.head.target) with mock.patch.dict( "pagure.config.config", @@ -360,7 +360,7 @@ class PagureFlaskUiArchivesTest(tests.Modeltests): """Test getting the archive from a commit.""" repopath = os.path.join(self.path, "repos", "test.git") repo = pygit2.Repository(repopath) - commit = repo.head.target.hex + commit = str(repo.head.target) with mock.patch.dict( "pagure.config.config", {"ARCHIVE_FOLDER": os.path.join(self.path, "archives")}, @@ -386,7 +386,7 @@ class PagureFlaskUiArchivesTest(tests.Modeltests): disk cache.""" repopath = os.path.join(self.path, "repos", "test.git") repo = pygit2.Repository(repopath) - commit = repo.head.target.hex + commit = str(repo.head.target) with mock.patch.dict( "pagure.config.config", {"ARCHIVE_FOLDER": os.path.join(self.path, "archives")}, diff --git a/tests/test_pagure_flask_ui_fork.py b/tests/test_pagure_flask_ui_fork.py index 1630128..b832021 100644 --- a/tests/test_pagure_flask_ui_fork.py +++ b/tests/test_pagure_flask_ui_fork.py @@ -95,7 +95,7 @@ def set_up_git_repo( try: com = repo.revparse_single("HEAD") - prev_commit = [com.oid.hex] + prev_commit = [str(com.id)] except: prev_commit = [] @@ -145,7 +145,7 @@ def set_up_git_repo( # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/master:refs/heads/master" ori_remote = clone_repo.remotes[0] @@ -169,7 +169,7 @@ def set_up_git_repo( # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/master:refs/heads/master" ori_remote = clone_repo.remotes[0] @@ -204,7 +204,7 @@ def set_up_git_repo( committer, "A commit on branch %s\n\nMore information" % branch_from, tree, - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/%s" % (branch_from) ori_remote = repo.remotes[0] @@ -551,7 +551,7 @@ class PagureFlaskForktests(tests.Modeltests): clone_repo.index.write() com = clone_repo.revparse_single("HEAD") - prev_commit = [com.oid.hex] + prev_commit = [str(com.id)] # Commits the files added tree = clone_repo.index.write_tree() @@ -5413,7 +5413,7 @@ More information parents = [] try: last_commit = clone_repo.revparse_single("HEAD") - parents = [last_commit.oid.hex] + parents = [str(last_commit.id)] except KeyError: pass @@ -5470,7 +5470,7 @@ More information # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [last_commit.oid.hex], + [str(last_commit.id)], ) # Push to the fork repo @@ -7236,7 +7236,7 @@ More information # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [last_commit.oid.hex], + [str(last_commit.id)], ) # Second commit @@ -7258,7 +7258,7 @@ More information # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [last_commit.oid.hex], + [str(last_commit.id)], ) # Third commit @@ -7280,7 +7280,7 @@ More information # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [last_commit.oid.hex], + [str(last_commit.id)], ) refname = "refs/heads/master:refs/heads/master" diff --git a/tests/test_pagure_flask_ui_issue_pr_link.py b/tests/test_pagure_flask_ui_issue_pr_link.py index 5379771..0c2d6f3 100644 --- a/tests/test_pagure_flask_ui_issue_pr_link.py +++ b/tests/test_pagure_flask_ui_issue_pr_link.py @@ -91,7 +91,7 @@ class PagureFlaskPrIssueLinkTest(tests.Modeltests): try: com = repo.revparse_single("HEAD") - prev_commit = [com.oid.hex] + prev_commit = [str(com.id)] except: prev_commit = [] diff --git a/tests/test_pagure_flask_ui_issues_templates.py b/tests/test_pagure_flask_ui_issues_templates.py index ff8849c..7cd6f52 100644 --- a/tests/test_pagure_flask_ui_issues_templates.py +++ b/tests/test_pagure_flask_ui_issues_templates.py @@ -72,7 +72,7 @@ def create_templates(repopath): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [commit.hex], + [str(commit)], ) # Create the default.md template @@ -94,7 +94,7 @@ def create_templates(repopath): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [commit.hex], + [str(commit)], ) diff --git a/tests/test_pagure_flask_ui_no_master_branch.py b/tests/test_pagure_flask_ui_no_master_branch.py index 3ba928d..1deef48 100644 --- a/tests/test_pagure_flask_ui_no_master_branch.py +++ b/tests/test_pagure_flask_ui_no_master_branch.py @@ -65,7 +65,7 @@ class PagureFlaskNoMasterBranchtests(tests.SimplePagureTest): ) feature_branch = clone_repo.lookup_branch("feature") - first_commit = feature_branch.peel().hex + first_commit = str(feature_branch.peel().id) # Second commit with open(os.path.join(repopath, ".gitignore"), "w") as stream: diff --git a/tests/test_pagure_flask_ui_old_commit.py b/tests/test_pagure_flask_ui_old_commit.py index a8e8232..1190b7c 100644 --- a/tests/test_pagure_flask_ui_old_commit.py +++ b/tests/test_pagure_flask_ui_old_commit.py @@ -65,11 +65,11 @@ class PagureFlaskRepoOldUrltests(tests.SimplePagureTest): commit = repo.revparse_single("HEAD") # View first commit - output = self.app.get("/test/%s" % commit.oid.hex) + output = self.app.get("/test/%s" % str(commit.id)) self.assertEqual(output.status_code, 302) output = self.app.get( - "/test/%s" % commit.oid.hex, follow_redirects=True + "/test/%s" % str(commit.id), follow_redirects=True ) self.assertEqual(output.status_code, 200) self.assertTrue( @@ -83,13 +83,13 @@ class PagureFlaskRepoOldUrltests(tests.SimplePagureTest): ) self.assertTrue( - 'title="View file as of %s"' % commit.oid.hex[0:7] + 'title="View file as of %s"' % str(commit.id)[0:7] in output.get_data(as_text=True) ) # View first commit - with the old URL scheme output = self.app.get( - "/test/%s" % commit.oid.hex, follow_redirects=True + "/test/%s" % str(commit.id), follow_redirects=True ) self.assertEqual(output.status_code, 200) self.assertTrue( @@ -112,7 +112,7 @@ class PagureFlaskRepoOldUrltests(tests.SimplePagureTest): # View another commit output = self.app.get( - "/test/%s" % commit.oid.hex, follow_redirects=True + "/test/%s" % str(commit.id), follow_redirects=True ) self.assertEqual(output.status_code, 200) self.assertTrue( @@ -148,13 +148,13 @@ class PagureFlaskRepoOldUrltests(tests.SimplePagureTest): # Commit does not exist in anothe repo :) output = self.app.get( - "/test/%s" % commit.oid.hex, follow_redirects=True + "/test/%s" % str(commit.id), follow_redirects=True ) self.assertEqual(output.status_code, 404) # View commit of fork output = self.app.get( - "/fork/pingou/test3/%s" % commit.oid.hex, follow_redirects=True + "/fork/pingou/test3/%s" % str(commit.id), follow_redirects=True ) self.assertEqual(output.status_code, 200) self.assertTrue( @@ -168,13 +168,13 @@ class PagureFlaskRepoOldUrltests(tests.SimplePagureTest): ) self.assertTrue( - 'title="View file as of %s"' % commit.oid.hex[0:7] + 'title="View file as of %s"' % str(commit.id)[0:7] in output.get_data(as_text=True) ) # View commit of fork - With the old URL scheme output = self.app.get( - "/fork/pingou/test3/%s" % commit.oid.hex, follow_redirects=True + "/fork/pingou/test3/%s" % str(commit.id), follow_redirects=True ) self.assertEqual(output.status_code, 200) self.assertTrue( @@ -189,7 +189,7 @@ class PagureFlaskRepoOldUrltests(tests.SimplePagureTest): # Try the old URL scheme with a short hash output = self.app.get( - "/fork/pingou/test3/%s" % commit.oid.hex[:10], + "/fork/pingou/test3/%s" % str(commit.id)[:10], follow_redirects=True, ) self.assertEqual(output.status_code, 404) diff --git a/tests/test_pagure_flask_ui_remote_pr.py b/tests/test_pagure_flask_ui_remote_pr.py index 1aa0fe1..7e4ef69 100644 --- a/tests/test_pagure_flask_ui_remote_pr.py +++ b/tests/test_pagure_flask_ui_remote_pr.py @@ -75,7 +75,7 @@ class PagureRemotePRtests(tests.Modeltests): try: com = repo.revparse_single("HEAD") - prev_commit = [com.oid.hex] + prev_commit = [str(com.id)] except: prev_commit = [] @@ -117,7 +117,7 @@ class PagureRemotePRtests(tests.Modeltests): # binary string representing the tree object ID tree, # list of binary strings representing parents of the new commit - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/master:refs/heads/master" ori_remote = clone_repo.remotes[0] @@ -151,7 +151,7 @@ class PagureRemotePRtests(tests.Modeltests): committer, "A commit on branch %s" % branch_from, tree, - [first_commit.oid.hex], + [str(first_commit.id)], ) refname = "refs/heads/%s" % (branch_from) ori_remote = repo.remotes[0] diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index 7723250..e5c32ce 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -2637,7 +2637,7 @@ class PagureFlaskRepotests(tests.Modeltests): tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0) repo.create_tag( "0.0.1", - first_commit.oid.hex, + str(first_commit.id), pygit2.GIT_OBJ_COMMIT, tagger, "Release 0.0.1", @@ -2650,8 +2650,8 @@ class PagureFlaskRepotests(tests.Modeltests): output = self.app.get("/test/commits/0.0.1") self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) - self.assertIn(first_commit.oid.hex, output_text) - self.assertNotIn(latest_commit.oid.hex, output_text) + self.assertIn(str(first_commit.id), output_text) + self.assertNotIn(str(latest_commit.id), output_text) self.assertIn("Commits - test - Pagure", output_text) self.assertEqual(output_text.count(''), 1) @@ -2672,7 +2672,7 @@ class PagureFlaskRepotests(tests.Modeltests): repo_obj, commit.tree, ["sources"], bail_on_tree=True ) - output = self.app.get("/test/commits/%s" % content.oid.hex) + output = self.app.get("/test/commits/%s" % str(content.id)) self.assertEqual(output.status_code, 404) output_text = output.get_data(as_text=True) self.assertIn("Invalid branch/identifier provided", output_text) @@ -2690,7 +2690,7 @@ class PagureFlaskRepotests(tests.Modeltests): tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0) repo.create_tag( "0.0.1", - first_commit.oid.hex, + str(first_commit.id), pygit2.GIT_OBJ_COMMIT, tagger, "Release 0.0.1", @@ -2700,8 +2700,8 @@ class PagureFlaskRepotests(tests.Modeltests): repo = pygit2.Repository(os.path.join(self.path, "repos", "test.git")) project = pagure.lib.query.get_authorized_project(self.session, "test") tags = pagure.lib.git.get_git_tags_objects(project) - tag_id = tags[0]["object"].oid - commit_id = tags[0]["object"].peel(pygit2.Commit).hex + tag_id = tags[0]["object"].id + commit_id = str(tags[0]["object"].peel(pygit2.Commit).id) output = self.app.get("/test/c/%s" % tag_id) self.assertEqual(output.status_code, 302) @@ -2709,7 +2709,7 @@ class PagureFlaskRepotests(tests.Modeltests): output = self.app.get("/test/c/%s" % tag_id, follow_redirects=True) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) - self.assertIn(first_commit.oid.hex, output_text) + self.assertIn(str(first_commit.id), output_text) self.assertIn( "Commit - test - %s - Pagure" % commit_id, output_text, @@ -2721,17 +2721,17 @@ class PagureFlaskRepotests(tests.Modeltests): # First two commits comparison def compare_first_two(c1, c2): # View commits comparison - output = self.app.get("/test/c/%s..%s" % (c2.oid.hex, c1.oid.hex)) + output = self.app.get("/test/c/%s..%s" % (str(c2.id), str(c1.id))) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( "Diff from %s to %s - test\n - Pagure" - % (c2.oid.hex, c1.oid.hex), + % (str(c2.id), str(c1.id)), output_text, ) self.assertIn( ' %s\n ..\n %s\n' - % (c2.oid.hex, c1.oid.hex), + % (str(c2.id), str(c1.id)), output_text, ) self.assertNotIn('id="show_hidden_commits"', output_text) @@ -2740,18 +2740,18 @@ class PagureFlaskRepotests(tests.Modeltests): output_text, ) # View inverse commits comparison - output = self.app.get("/test/c/%s..%s" % (c1.oid.hex, c2.oid.hex)) + output = self.app.get("/test/c/%s..%s" % (str(c1.id), str(c2.id))) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( "Diff from %s to %s - test\n - Pagure" - % (c1.oid.hex, c2.oid.hex), + % (str(c1.id), str(c2.id)), output_text, ) self.assertNotIn('id="show_hidden_commits"', output_text) self.assertIn( ' %s\n ..\n %s\n' - % (c1.oid.hex, c2.oid.hex), + % (str(c1.id), str(c2.id)), output_text, ) self.assertIn( @@ -2761,17 +2761,17 @@ class PagureFlaskRepotests(tests.Modeltests): def compare_all(c1, c3): # View commits comparison - output = self.app.get("/test/c/%s..%s" % (c1.oid.hex, c3.oid.hex)) + output = self.app.get("/test/c/%s..%s" % (str(c1.id), str(c3.id))) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( "Diff from %s to %s - test\n - Pagure" - % (c1.oid.hex, c3.oid.hex), + % (str(c1.id), str(c3.id)), output_text, ) self.assertIn( ' %s\n ..\n %s\n' - % (c1.oid.hex, c3.oid.hex), + % (str(c1.id), str(c3.id)), output_text, ) self.assertIn( @@ -2795,17 +2795,17 @@ class PagureFlaskRepotests(tests.Modeltests): ) # View inverse commits comparison - output = self.app.get("/test/c/%s..%s" % (c3.oid.hex, c1.oid.hex)) + output = self.app.get("/test/c/%s..%s" % (str(c3.id), str(c1.id))) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( "Diff from %s to %s - test\n - Pagure" - % (c3.oid.hex, c1.oid.hex), + % (str(c3.id), str(c1.id)), output_text, ) self.assertIn( ' %s\n ..\n %s\n' - % (c3.oid.hex, c1.oid.hex), + % (str(c3.id), str(c1.id)), output_text, ) self.assertIn( @@ -2830,13 +2830,13 @@ class PagureFlaskRepotests(tests.Modeltests): # View comparison of commits with symlink # we only test that the patch itself renders correctly, # the rest of the logic is already tested in the other functions - output = self.app.get("/test/c/%s..%s" % (c3.oid.hex, c4.oid.hex)) + output = self.app.get("/test/c/%s..%s" % (str(c3.id), str(c4.id))) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) print(output_text) self.assertIn( "Diff from %s to %s - test\n - Pagure" - % (c3.oid.hex, c4.oid.hex), + % (str(c3.id), str(c4.id)), output_text, ) self.assertIn( @@ -2970,7 +2970,7 @@ class PagureFlaskRepotests(tests.Modeltests): repo = pygit2.Repository(os.path.join(self.path, "repos", "test.git")) commit = repo.revparse_single("HEAD") - output = self.app.get("/test/blob/%s/f/test.jpg" % commit.oid.hex) + output = self.app.get("/test/blob/%s/f/test.jpg" % str(commit.id)) self.assertEqual(output.status_code, 200) self.assertNotIn(b"+1", output_text) # View the commit when branch name is provided - output = self.app.get("/test/c/%s?branch=master" % commit.oid.hex) + output = self.app.get("/test/c/%s?branch=master" % str(commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( @@ -3367,7 +3367,7 @@ class PagureFlaskRepotests(tests.Modeltests): ) # View the commit when branch name is wrong, show the commit - output = self.app.get("/test/c/%s?branch=abcxyz" % commit.oid.hex) + output = self.app.get("/test/c/%s?branch=abcxyz" % str(commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( @@ -3400,11 +3400,11 @@ class PagureFlaskRepotests(tests.Modeltests): commit = repo.revparse_single("HEAD") # Commit does not exist in anothe repo :) - output = self.app.get("/test/c/%s" % commit.oid.hex) + output = self.app.get("/test/c/%s" % str(commit.id)) self.assertEqual(output.status_code, 404) # View commit of fork - output = self.app.get("/fork/pingou/test3/c/%s" % commit.oid.hex) + output = self.app.get("/fork/pingou/test3/c/%s" % str(commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn("#commit-overview-collapse", output_text) @@ -3413,7 +3413,7 @@ class PagureFlaskRepotests(tests.Modeltests): # Try the old URL scheme with a short hash output = self.app.get( - "/fork/pingou/test3/%s" % commit.oid.hex[:10], + "/fork/pingou/test3/%s" % str(commit.id)[:10], follow_redirects=True, ) self.assertEqual(output.status_code, 404) @@ -3422,7 +3422,7 @@ class PagureFlaskRepotests(tests.Modeltests): # View the commit of the fork when branch name is provided output = self.app.get( - "/fork/pingou/test3/c/%s?branch=master" % commit.oid.hex + "/fork/pingou/test3/c/%s?branch=master" % str(commit.id) ) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) @@ -3437,7 +3437,7 @@ class PagureFlaskRepotests(tests.Modeltests): # View the commit of the fork when branch name is wrong output = self.app.get( - "/fork/pingou/test3/c/%s?branch=abcxyz" % commit.oid.hex + "/fork/pingou/test3/c/%s?branch=abcxyz" % str(commit.id) ) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) @@ -3476,7 +3476,7 @@ class PagureFlaskRepotests(tests.Modeltests): commit = repo.revparse_single("HEAD") # View first commit - output = self.app.get("/test/c/%s" % commit.oid.hex) + output = self.app.get("/test/c/%s" % str(commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn("#commit-overview-collapse", output_text) @@ -3520,7 +3520,7 @@ class PagureFlaskRepotests(tests.Modeltests): commit = repo.revparse_single("HEAD") # View first commit - output = self.app.get("/test/c/%s" % commit.oid.hex) + output = self.app.get("/test/c/%s" % str(commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn("#commit-overview-collapse", output_text) @@ -3560,7 +3560,7 @@ class PagureFlaskRepotests(tests.Modeltests): commit = repo.revparse_single("HEAD") # View first commit - output = self.app.get("/test/c/%s.patch" % commit.oid.hex) + output = self.app.get("/test/c/%s.patch" % str(commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( @@ -3600,7 +3600,7 @@ index 0000000..fb7093d commit = repo.revparse_single("HEAD") # View another commit - output = self.app.get("/test/c/%s.patch" % commit.oid.hex) + output = self.app.get("/test/c/%s.patch" % str(commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( @@ -3644,11 +3644,11 @@ index 0000000..11980b1 commit = repo.revparse_single("HEAD") # Commit does not exist in anothe repo :) - output = self.app.get("/test/c/%s.patch" % commit.oid.hex) + output = self.app.get("/test/c/%s.patch" % str(commit.id)) self.assertEqual(output.status_code, 404) # View commit of fork - output = self.app.get("/fork/pingou/test3/c/%s.patch" % commit.oid.hex) + output = self.app.get("/fork/pingou/test3/c/%s.patch" % str(commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( @@ -3702,7 +3702,7 @@ index 0000000..fb7093d commit = repo.revparse_single("HEAD") # View first commit - output = self.app.get("/test/c/%s.diff" % commit.oid.hex) + output = self.app.get("/test/c/%s.diff" % str(commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertEqual( @@ -3768,7 +3768,7 @@ index 0000000..fb7093d commit = repo.revparse_single("HEAD") # View first commit - output = self.app.get("/test/tree/%s" % commit.oid.hex) + output = self.app.get("/test/tree/%s" % str(commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn("Tree - test - Pagure", output_text) @@ -5012,7 +5012,7 @@ index 0000000..fb7093d tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0) repo.create_tag( "0.0.1", - first_commit.oid.hex, + str(first_commit.id), pygit2.GIT_OBJ_COMMIT, tagger, "Release 0.0.1", diff --git a/tests/test_pagure_flask_ui_repo_flag_commit.py b/tests/test_pagure_flask_ui_repo_flag_commit.py index ff416a5..c88d876 100644 --- a/tests/test_pagure_flask_ui_repo_flag_commit.py +++ b/tests/test_pagure_flask_ui_repo_flag_commit.py @@ -44,10 +44,10 @@ class ViewCommitFlagtests(tests.SimplePagureTest): """Test the view_commit endpoint.""" # View first commit - output = self.app.get("/test/c/%s" % self.commit.oid.hex) + output = self.app.get("/test/c/%s" % str(self.commit.id)) self.assertEqual(output.status_code, 200) self.assertIn( - "Commit - test - %s - Pagure" % self.commit.oid.hex, + "Commit - test - %s - Pagure" % str(self.commit.id), output.get_data(as_text=True), ) self.assertIn( @@ -65,7 +65,7 @@ class ViewCommitFlagtests(tests.SimplePagureTest): msg = pagure.lib.query.add_commit_flag( session=self.session, repo=repo, - commit_hash=self.commit.oid.hex, + commit_hash=str(self.commit.id), username="simple-koji-ci", status="pending", percent=None, @@ -79,11 +79,11 @@ class ViewCommitFlagtests(tests.SimplePagureTest): self.assertEqual(msg, ("Flag added", "uid")) # View first commit - output = self.app.get("/test/c/%s" % self.commit.oid.hex) + output = self.app.get("/test/c/%s" % str(self.commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - "Commit - test - %s - Pagure" % self.commit.oid.hex, + "Commit - test - %s - Pagure" % str(self.commit.id), output_text, ) self.assertIn("#commit-overview-collapse", output_text) @@ -110,7 +110,7 @@ class ViewCommitFlagtests(tests.SimplePagureTest): msg = pagure.lib.query.add_commit_flag( session=self.session, repo=repo, - commit_hash=self.commit.oid.hex, + commit_hash=str(self.commit.id), username="simple-koji-ci", status="success", percent=100, @@ -124,11 +124,11 @@ class ViewCommitFlagtests(tests.SimplePagureTest): self.assertEqual(msg, ("Flag added", "uid")) # View first commit - output = self.app.get("/test/c/%s" % self.commit.oid.hex) + output = self.app.get("/test/c/%s" % str(self.commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - "Commit - test - %s - Pagure" % self.commit.oid.hex, + "Commit - test - %s - Pagure" % str(self.commit.id), output_text, ) self.assertIn("#commit-overview-collapse", output_text) @@ -155,7 +155,7 @@ class ViewCommitFlagtests(tests.SimplePagureTest): msg = pagure.lib.query.add_commit_flag( session=self.session, repo=repo, - commit_hash=self.commit.oid.hex, + commit_hash=str(self.commit.id), username="simple-koji-ci", status="error", percent=None, @@ -169,11 +169,11 @@ class ViewCommitFlagtests(tests.SimplePagureTest): self.assertEqual(msg, ("Flag added", "uid")) # View first commit - output = self.app.get("/test/c/%s" % self.commit.oid.hex) + output = self.app.get("/test/c/%s" % str(self.commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - "Commit - test - %s - Pagure" % self.commit.oid.hex, + "Commit - test - %s - Pagure" % str(self.commit.id), output_text, ) self.assertIn("#commit-overview-collapse", output_text) @@ -200,7 +200,7 @@ class ViewCommitFlagtests(tests.SimplePagureTest): msg = pagure.lib.query.add_commit_flag( session=self.session, repo=repo, - commit_hash=self.commit.oid.hex, + commit_hash=str(self.commit.id), username="simple-koji-ci", status="failure", percent=None, @@ -214,11 +214,11 @@ class ViewCommitFlagtests(tests.SimplePagureTest): self.assertEqual(msg, ("Flag added", "uid")) # View first commit - output = self.app.get("/test/c/%s" % self.commit.oid.hex) + output = self.app.get("/test/c/%s" % str(self.commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - "Commit - test - %s - Pagure" % self.commit.oid.hex, + "Commit - test - %s - Pagure" % str(self.commit.id), output_text, ) self.assertIn("#commit-overview-collapse", output_text) @@ -244,7 +244,7 @@ class ViewCommitFlagtests(tests.SimplePagureTest): msg = pagure.lib.query.add_commit_flag( session=self.session, repo=repo, - commit_hash=self.commit.oid.hex, + commit_hash=str(self.commit.id), username="simple-koji-ci", status="canceled", percent=None, @@ -258,11 +258,11 @@ class ViewCommitFlagtests(tests.SimplePagureTest): self.assertEqual(msg, ("Flag added", "uid")) # View first commit - output = self.app.get("/test/c/%s" % self.commit.oid.hex) + output = self.app.get("/test/c/%s" % str(self.commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - "Commit - test - %s - Pagure" % self.commit.oid.hex, + "Commit - test - %s - Pagure" % str(self.commit.id), output_text, ) self.assertIn("#commit-overview-collapse", output_text) @@ -297,7 +297,7 @@ class ViewCommitFlagtests(tests.SimplePagureTest): msg = pagure.lib.query.add_commit_flag( session=self.session, repo=repo, - commit_hash=self.commit.oid.hex, + commit_hash=str(self.commit.id), username="simple-koji-ci", status="status1", percent=None, @@ -311,11 +311,11 @@ class ViewCommitFlagtests(tests.SimplePagureTest): self.assertEqual(msg, ("Flag added", "uid")) # View first commit - output = self.app.get("/test/c/%s" % self.commit.oid.hex) + output = self.app.get("/test/c/%s" % str(self.commit.id)) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) self.assertIn( - "Commit - test - %s - Pagure" % self.commit.oid.hex, + "Commit - test - %s - Pagure" % str(self.commit.id), output_text, ) self.assertIn("#commit-overview-collapse", output_text) diff --git a/tests/test_pagure_flask_ui_repo_slash_name.py b/tests/test_pagure_flask_ui_repo_slash_name.py index ac09ecd..7003717 100644 --- a/tests/test_pagure_flask_ui_repo_slash_name.py +++ b/tests/test_pagure_flask_ui_repo_slash_name.py @@ -236,7 +236,7 @@ class PagureFlaskSlashInNametests(tests.SimplePagureTest): gitrepo = os.path.join(self.path, "repos", "forks/test.git") repo = pygit2.Repository(gitrepo) master_branch = repo.lookup_branch("master") - first_commit = master_branch.peel().hex + first_commit = str(master_branch.peel().id) output = self.app.get("/forks/test/commits") self.assertEqual(output.status_code, 200) diff --git a/tests/test_pagure_flask_ui_repo_view_blame.py b/tests/test_pagure_flask_ui_repo_view_blame.py index 78ebaf2..02e12bf 100644 --- a/tests/test_pagure_flask_ui_repo_view_blame.py +++ b/tests/test_pagure_flask_ui_repo_view_blame.py @@ -135,7 +135,7 @@ class PagureFlaskRepoViewBlameFiletests(tests.Modeltests): os.path.join(self.path, "repos", "test.git") ) commit = repo_obj[repo_obj.head.target] - parent = commit.parents[0].oid.hex + parent = str(commit.parents[0].id) output = self.app.get( "/test/blame/sources?identifier={}".format(parent) @@ -182,7 +182,7 @@ class PagureFlaskRepoViewBlameFiletests(tests.Modeltests): os.path.join(self.path, "repos", "test.git") ) commit = repo_obj[repo_obj.head.target] - parent = commit.parents[0].oid.hex + parent = str(commit.parents[0].id) tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0) repo_obj.create_tag( "v1.0", parent, pygit2.GIT_OBJ_COMMIT, tagger, "Release v1.0" @@ -217,7 +217,7 @@ class PagureFlaskRepoViewBlameFiletests(tests.Modeltests): ) output = self.app.get( - "/test/blame/sources?identifier=%s" % content.oid.hex + "/test/blame/sources?identifier=%s" % str(content.id) ) self.assertEqual(output.status_code, 404) output_text = output.get_data(as_text=True) diff --git a/tests/test_pagure_flask_ui_repo_view_file.py b/tests/test_pagure_flask_ui_repo_view_file.py index 3e40c52..c6bb65d 100644 --- a/tests/test_pagure_flask_ui_repo_view_file.py +++ b/tests/test_pagure_flask_ui_repo_view_file.py @@ -144,7 +144,7 @@ class PagureFlaskRepoViewFiletests(LocalBasetests): repo = pygit2.Repository(os.path.join(self.path, "repos", "test.git")) commit = repo.revparse_single("HEAD") - output = self.app.get("/test/blob/%s/f/test.jpg" % commit.oid.hex) + output = self.app.get("/test/blob/%s/f/test.jpg" % str(commit.id)) self.assertEqual(output.status_code, 200) self.assertNotIn(b" Date: Apr 15 2026 17:17:23 +0000 Subject: [PATCH 2/11] fix(pygit2): Stop using GIT_OBJ_COMMIT This no longer exists in pygit 1.15+ --- diff --git a/tests/test_pagure_flask_api_project.py b/tests/test_pagure_flask_api_project.py index e692db9..a3f573e 100644 --- a/tests/test_pagure_flask_api_project.py +++ b/tests/test_pagure_flask_api_project.py @@ -88,7 +88,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): repo.create_tag( "0.0.1", str(first_commit.id), - pygit2.GIT_OBJ_COMMIT, + pygit2.enums.ObjectType.COMMIT, tagger, "Release 0.0.1", ) diff --git a/tests/test_pagure_flask_api_project_view_file.py b/tests/test_pagure_flask_api_project_view_file.py index 2d000dc..c9d1f9e 100644 --- a/tests/test_pagure_flask_api_project_view_file.py +++ b/tests/test_pagure_flask_api_project_view_file.py @@ -298,7 +298,7 @@ class PagureFlaskApiProjectViewFiletests(tests.Modeltests): tag = repo.create_tag( "v1.0_tag", str(commit.id), - pygit2.GIT_OBJ_COMMIT, + pygit2.enums.ObjectType.COMMIT, tagger, "Release v1.0", ) diff --git a/tests/test_pagure_flask_api_ui_private_repo.py b/tests/test_pagure_flask_api_ui_private_repo.py index aa45da8..7e8a603 100644 --- a/tests/test_pagure_flask_api_ui_private_repo.py +++ b/tests/test_pagure_flask_api_ui_private_repo.py @@ -1233,7 +1233,7 @@ class PagurePrivateRepotest(tests.Modeltests): repo.create_tag( "0.0.1", str(first_commit.id), - pygit2.GIT_OBJ_COMMIT, + pygit2.enums.ObjectType.COMMIT, tagger, "Release 0.0.1", ) diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index e5c32ce..a68b6b4 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -2638,7 +2638,7 @@ class PagureFlaskRepotests(tests.Modeltests): repo.create_tag( "0.0.1", str(first_commit.id), - pygit2.GIT_OBJ_COMMIT, + pygit2.enums.ObjectType.COMMIT, tagger, "Release 0.0.1", ) @@ -2691,7 +2691,7 @@ class PagureFlaskRepotests(tests.Modeltests): repo.create_tag( "0.0.1", str(first_commit.id), - pygit2.GIT_OBJ_COMMIT, + pygit2.enums.ObjectType.COMMIT, tagger, "Release 0.0.1", ) @@ -5013,7 +5013,7 @@ index 0000000..fb7093d repo.create_tag( "0.0.1", str(first_commit.id), - pygit2.GIT_OBJ_COMMIT, + pygit2.enums.ObjectType.COMMIT, tagger, "Release 0.0.1", ) diff --git a/tests/test_pagure_flask_ui_repo_view_blame.py b/tests/test_pagure_flask_ui_repo_view_blame.py index 02e12bf..b12ea57 100644 --- a/tests/test_pagure_flask_ui_repo_view_blame.py +++ b/tests/test_pagure_flask_ui_repo_view_blame.py @@ -185,7 +185,7 @@ class PagureFlaskRepoViewBlameFiletests(tests.Modeltests): parent = str(commit.parents[0].id) tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0) repo_obj.create_tag( - "v1.0", parent, pygit2.GIT_OBJ_COMMIT, tagger, "Release v1.0" + "v1.0", parent, pygit2.enums.ObjectType.COMMIT, tagger, "Release v1.0" ) output = self.app.get("/test/blame/sources?identifier=v1.0") diff --git a/tests/test_pagure_flask_ui_repo_view_history.py b/tests/test_pagure_flask_ui_repo_view_history.py index fa69f6a..16494f7 100644 --- a/tests/test_pagure_flask_ui_repo_view_history.py +++ b/tests/test_pagure_flask_ui_repo_view_history.py @@ -143,7 +143,7 @@ class PagureFlaskRepoViewHistoryFiletests(tests.Modeltests): parent = str(commit.parents[0].id) tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0) repo_obj.create_tag( - "v1.0", parent, pygit2.GIT_OBJ_COMMIT, tagger, "Release v1.0" + "v1.0", parent, pygit2.enums.ObjectType.COMMIT, tagger, "Release v1.0" ) output = self.app.get("/test/history/sources?identifier=v1.0") diff --git a/tests/test_pagure_lib_git_get_tags_objects.py b/tests/test_pagure_lib_git_get_tags_objects.py index d235ed2..7d6b3cf 100644 --- a/tests/test_pagure_lib_git_get_tags_objects.py +++ b/tests/test_pagure_lib_git_get_tags_objects.py @@ -46,7 +46,7 @@ def add_repo_tag(git_dir, repo, tags, repo_name): repo.create_tag( tag, str(first_commit.id), - pygit2.GIT_OBJ_COMMIT, + pygit2.enums.ObjectType.COMMIT, tagger, "Release " + tag, ) From db542ae2db875a49679f2ede848be9da4403b0e2 Mon Sep 17 00:00:00 2001 From: Rebecca N. Palmer Date: Apr 15 2026 17:17:23 +0000 Subject: [PATCH 3/11] fix(pygit2): Accept new error type Together with the previous two, Fixes: https://pagure.io/pagure/issue/5492 --- diff --git a/tests/test_pagure_flask_internal.py b/tests/test_pagure_flask_internal.py index ad3d126..726d0d4 100644 --- a/tests/test_pagure_flask_internal.py +++ b/tests/test_pagure_flask_internal.py @@ -2001,6 +2001,7 @@ class PagureFlaskInternaltests(tests.Modeltests): in [ {"results": "reference 'refs/heads/master' not found"}, {"results": "Reference 'refs/heads/master' not found"}, + {"results": "GitError(\"reference 'refs/heads/master' not found\")"}, ] ) @@ -2143,6 +2144,7 @@ class PagureFlaskInternaltests(tests.Modeltests): in [ {"results": "reference 'refs/heads/master' not found"}, {"results": "Reference 'refs/heads/master' not found"}, + {"results": "GitError(\"reference 'refs/heads/master' not found\")"}, ] ) From dbf759d5bd995829d0bf939c4fa982e43a5df0e7 Mon Sep 17 00:00:00 2001 From: Rebecca N. Palmer Date: Apr 15 2026 17:17:23 +0000 Subject: [PATCH 4/11] Revert pygit2 version pin - no longer needed This reverts commit 0c13cf0d61694e5aa9c76adf7d41fb2aad70255f. --- diff --git a/requirements.txt b/requirements.txt index e74015e..1629498 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,7 +22,7 @@ markdown <= 3.5.2 munch <= 2.5.0 Pillow <= 10.3.0 psutil <= 5.9.8 -pygit2 < 1.15.0 +pygit2 python3-openid <= 3.2.0 python-openid-cla == 1.2 python-openid-teams == 1.1 From 4d50acc8dc39a21fd654079bed21445111ff1403 Mon Sep 17 00:00:00 2001 From: Rebecca N. Palmer Date: Apr 15 2026 17:17:23 +0000 Subject: [PATCH 5/11] fix(arrow): Don't assume arrow timestamp is a value In newer arrow, it's a method --- diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 9f54e5f..f558ff8 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -151,10 +151,10 @@ def create_default_status(session, acls=None): def arrow_ts(value): - if hasattr(arrow, "timestamp"): - return "%s" % arrow.get(value).timestamp # arrow < v1.0.0 - else: + try: return "%s" % arrow.get(value).float_timestamp # arrow >= v1.0.0 + except AttributeError: + return "%s" % arrow.get(value).timestamp # arrow < v1.0.0 class AccessLevels(BASE): From 1f6b040e772b7ff4a791bbc76ab12d279398288e Mon Sep 17 00:00:00 2001 From: Rebecca N. Palmer Date: Apr 15 2026 17:17:23 +0000 Subject: [PATCH 6/11] fix(werkzeug): Don't use __version__ It no longer exists in werkzeug 3.1+ --- diff --git a/tests/test_pagure_flask_ui_remote_pr.py b/tests/test_pagure_flask_ui_remote_pr.py index 7e4ef69..85778e1 100644 --- a/tests/test_pagure_flask_ui_remote_pr.py +++ b/tests/test_pagure_flask_ui_remote_pr.py @@ -174,22 +174,18 @@ class PagureRemotePRtests(tests.Modeltests): # Try creating a remote PR output = self.app.get("/test/diff/remote") self.assertEqual(output.status_code, 302) - expected_response = ( + expected_responses = ( "You should be redirected automatically to target URL: " + '= (2, 1, 2): - expected_response = ( - "You should be redirected automatically to the target URL: " - ' Date: Apr 15 2026 17:17:23 +0000 Subject: [PATCH 7/11] fix(python): Don't use cgi or invalid escapes Based on git-multimail ddc9a1c + eb590c3 by Matthieu Moy and Ville Skyttä --- diff --git a/pagure/hooks/files/git_multimail_upstream.py b/pagure/hooks/files/git_multimail_upstream.py index 14b8911..5c09d3a 100755 --- a/pagure/hooks/files/git_multimail_upstream.py +++ b/pagure/hooks/files/git_multimail_upstream.py @@ -67,7 +67,7 @@ except ImportError: # Python < 2.6 do not have ssl, but that's OK if we don't use it. pass import time -import cgi +import html PYTHON3 = sys.version_info >= (3, 0) @@ -888,7 +888,7 @@ class Change(object): if html_escape_val: for k in values: if is_string(values[k]): - values[k] = cgi.escape(values[k], True) + values[k] = html.escape(values[k], True) for line in template.splitlines(True): yield line % values @@ -971,7 +971,7 @@ class Change(object): yield "
\n"
 
             for line in lines:
-                yield cgi.escape(line)
+                yield html.escape(line)
 
             yield "
\n" else: @@ -1049,7 +1049,7 @@ class Change(object): fgcolor = "404040" # Chop the trailing LF, we don't want it inside
.
-                line = cgi.escape(line[:-1])
+                line = html.escape(line[:-1])
 
                 if bgcolor or fgcolor:
                     style = "display:block; white-space:pre;"
@@ -3362,7 +3362,7 @@ class StashEnvironmentHighPrecMixin(Environment):
         self.__repo = repo
 
     def get_pusher(self):
-        return re.match("(.*?)\s*<", self.__user).group(1)
+        return re.match(r"(.*?)\s*<", self.__user).group(1)
 
     def get_pusher_email(self):
         return self.__user
@@ -3397,7 +3397,7 @@ class GerritEnvironmentHighPrecMixin(Environment):
             if self.__submitter.find("<") != -1:
                 # Submitter has a configured email, we transformed
                 # __submitter into an RFC 2822 string already.
-                return re.match("(.*?)\s*<", self.__submitter).group(1)
+                return re.match(r"(.*?)\s*<", self.__submitter).group(1)
             else:
                 # Submitter has no configured email, it's just his name.
                 return self.__submitter

From 83c8d3ef1b43ffc3e8c746edb9b0a19ed716a096 Mon Sep 17 00:00:00 2001
From: Rebecca N. Palmer 
Date: Apr 15 2026 17:17:23 +0000
Subject: [PATCH 8/11] commit vs id + style fixup


---

diff --git a/pagure/lib/git.py b/pagure/lib/git.py
index 64dd6ff..17a7fdc 100644
--- a/pagure/lib/git.py
+++ b/pagure/lib/git.py
@@ -2189,10 +2189,9 @@ def diff_pull_request(
         first_commit = diff_commits[-1]
         # Check if we can still rely on the merge_status
         commenttext = None
-        if (
-            request.commit_start != str(first_commit.id)
-            or request.commit_stop != str(diff_commits[0].id)
-        ):
+        if request.commit_start != str(
+            first_commit.id
+        ) or request.commit_stop != str(diff_commits[0].id):
             request.merge_status = None
             if request.commit_start:
                 pr_action = "updated"
@@ -2216,9 +2215,8 @@ def diff_pull_request(
                         new_commits_count,
                         commenttext,
                     )
-            if (
-                request.commit_start
-                and request.commit_start != str(first_commit.id)
+            if request.commit_start and request.commit_start != str(
+                first_commit.id
             ):
                 pr_action = "rebased"
                 if orig_commit:
diff --git a/tests/__init__.py b/tests/__init__.py
index 3c71a9b..3fca916 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -833,7 +833,7 @@ def add_content_git_repo(
 
     if extra_commit:
         if commit:
-            parents = [str(commit.id)]
+            parents = [str(commit)]
 
         # Create another file in that git repo
         with open(os.path.join(newfolder, "test"), "w") as stream:
diff --git a/tests/test_pagure_flask_internal.py b/tests/test_pagure_flask_internal.py
index 726d0d4..33e7edb 100644
--- a/tests/test_pagure_flask_internal.py
+++ b/tests/test_pagure_flask_internal.py
@@ -2001,7 +2001,9 @@ class PagureFlaskInternaltests(tests.Modeltests):
             in [
                 {"results": "reference 'refs/heads/master' not found"},
                 {"results": "Reference 'refs/heads/master' not found"},
-                {"results": "GitError(\"reference 'refs/heads/master' not found\")"},
+                {
+                    "results": "GitError(\"reference 'refs/heads/master' not found\")"
+                },
             ]
         )
 
@@ -2144,7 +2146,9 @@ class PagureFlaskInternaltests(tests.Modeltests):
             in [
                 {"results": "reference 'refs/heads/master' not found"},
                 {"results": "Reference 'refs/heads/master' not found"},
-                {"results": "GitError(\"reference 'refs/heads/master' not found\")"},
+                {
+                    "results": "GitError(\"reference 'refs/heads/master' not found\")"
+                },
             ]
         )
 
diff --git a/tests/test_pagure_flask_ui_remote_pr.py b/tests/test_pagure_flask_ui_remote_pr.py
index 85778e1..caf4b44 100644
--- a/tests/test_pagure_flask_ui_remote_pr.py
+++ b/tests/test_pagure_flask_ui_remote_pr.py
@@ -178,14 +178,14 @@ class PagureRemotePRtests(tests.Modeltests):
             "You should be redirected automatically to target URL: "
             '
Date: Apr 15 2026 17:17:23 +0000
Subject: [PATCH 9/11] more id fixup


---

diff --git a/pagure/api/project.py b/pagure/api/project.py
index 834bbef..097aa1e 100644
--- a/pagure/api/project.py
+++ b/pagure/api/project.py
@@ -2222,7 +2222,7 @@ def api_commit_info(repo, commit_hash, username=None, namespace=None):
         "commit_time_offset": commit_obj.commit_time_offset,
         "hash": str(commit_obj.id),
         "message": commit_obj.message,
-        "parent_ids": [str(h.id) for h in commit_obj.parent_ids],
+        "parent_ids": [str(h) for h in commit_obj.parent_ids],
         "tree_id": str(commit_obj.tree_id),
     }
 
diff --git a/tests/test_pagure_lib_git_diff_pr.py b/tests/test_pagure_lib_git_diff_pr.py
index ac738b8..622638d 100644
--- a/tests/test_pagure_lib_git_diff_pr.py
+++ b/tests/test_pagure_lib_git_diff_pr.py
@@ -201,7 +201,7 @@ class PagureFlaskForkPrtests(tests.Modeltests):
             # binary string representing the tree object ID
             tree,
             # list of binary strings representing parents of the new commit
-            [str(last_commit.id)],
+            [str(last_commit)],
         )
 
         # Push to the fork repo

From a297797b010e7c6f78138a710fd08c0a1159e203 Mon Sep 17 00:00:00 2001
From: Rebecca N. Palmer 
Date: Apr 15 2026 17:17:23 +0000
Subject: [PATCH 10/11] more id fixup


---

diff --git a/tests/test_pagure_flask_api_project.py b/tests/test_pagure_flask_api_project.py
index a3f573e..25c0f12 100644
--- a/tests/test_pagure_flask_api_project.py
+++ b/tests/test_pagure_flask_api_project.py
@@ -4903,7 +4903,7 @@ class PagureFlaskApiProjectCommitInfotests(tests.Modeltests):
             "committer": "Cecil Committer",
             "hash": str(self.commit.id),
             "message": "Add some directory and a file for more testing",
-            "parent_ids": [str(self.commit.parent_ids[0].id)],
+            "parent_ids": [str(self.commit.parent_ids[0])],
             "tree_id": str(self.commit.tree_id),
         }
 

From feab657e356464f3691c6a6517b5312e1dccd883 Mon Sep 17 00:00:00 2001
From: Rebecca N. Palmer 
Date: Apr 15 2026 17:17:23 +0000
Subject: [PATCH 11/11] fix(pip): Pin pygit2 version < 1.17


---

diff --git a/requirements.txt b/requirements.txt
index 1629498..ff04100 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -22,7 +22,7 @@ markdown <= 3.5.2
 munch <= 2.5.0
 Pillow <= 10.3.0
 psutil <= 5.9.8
-pygit2
+pygit2 < 1.17.0
 python3-openid <= 3.2.0
 python-openid-cla == 1.2
 python-openid-teams == 1.1