#5514 Be compatible with newer versions of dependencies (mostly pygit2)
Opened 5 months ago by rebecca-palmer. Modified 5 months ago
rebecca-palmer/pagure newpygit2etc  into  master

file modified
+2 -2
@@ -570,7 +570,7 @@ 

      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 @@ 

      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)):

file modified
+8 -8
@@ -1605,7 +1605,7 @@ 

                  )

  

      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 @@ 

  

      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 @@ 

          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 @@ 

          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:

file modified
+4 -4
@@ -920,7 +920,7 @@ 

              raise pagure.exceptions.APIError(

                  404, error_code=APIERROR.EFILENOTFOUND

              )

-         content = repo_obj[content.oid]

+         content = repo_obj[content.id]

      else:

          content = commit

  
@@ -2219,10 +2219,10 @@ 

          "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) for h in commit_obj.parent_ids],

+         "tree_id": str(commit_obj.tree_id),

      }

  

      return flask.jsonify(info)

file modified
+3 -3
@@ -100,7 +100,7 @@ 

                      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 @@ 

      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 @@ 

      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(

@@ -67,7 +67,7 @@ 

      # 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 @@ 

          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 @@ 

              yield "<pre style='margin:0'>\n"

  

              for line in lines:

-                 yield cgi.escape(line)

+                 yield html.escape(line)

  

              yield "</pre>\n"

          else:
@@ -1049,7 +1049,7 @@ 

                      fgcolor = "404040"

  

                  # Chop the trailing LF, we don't want it inside <pre>.

-                 line = cgi.escape(line[:-1])

+                 line = html.escape(line[:-1])

  

                  if bgcolor or fgcolor:

                      style = "display:block; white-space:pre;"
@@ -3362,7 +3362,7 @@ 

          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 @@ 

              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

file modified
+7 -7
@@ -606,20 +606,20 @@ 

  

              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 @@ 

      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)

file modified
+44 -46
@@ -126,7 +126,7 @@ 

  

  {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 @@ 

          # 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 @@ 

          # 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 @@ 

          # 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 @@ 

                  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 @@ 

  

          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 @@ 

              # 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 @@ 

                      _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 @@ 

                              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 @@ 

                  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 @@ 

                          # 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 @@ 

                          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 @@ 

                  _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 @@ 

                      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 @@ 

  

      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 @@ 

              "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 @@ 

              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 @@ 

                  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 @@ 

          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 @@ 

              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)
@@ -2189,17 +2189,16 @@ 

          first_commit = diff_commits[-1]

          # 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

-         ):

+         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"

                  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" % (
@@ -2216,17 +2215,16 @@ 

                          new_commits_count,

                          commenttext,

                      )

-             if (

-                 request.commit_start

-                 and request.commit_start != first_commit.oid.hex

+             if request.commit_start 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 +2333,7 @@ 

                  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 +2455,7 @@ 

              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 +2498,7 @@ 

              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 +2515,7 @@ 

      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(

file modified
+3 -3
@@ -151,10 +151,10 @@ 

  

  

  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):

file modified
+3 -3
@@ -787,7 +787,7 @@ 

      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 @@ 

  

      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 @@ 

      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,

      ):

  

file modified
+4 -4
@@ -69,12 +69,12 @@ 

                  'ui_ns.view_tree', username=username, namespace=repo.namespace,

                  repo=repo.name, identifier=commitid) }}">tree</a>

                {% if commit.parents|length == 1 %}

-               <a class="btn btn-outline-primary btn-sm" title={{commit.parents[0].oid.hex}} href="{{ url_for(

+               <a class="btn btn-outline-primary btn-sm" title={{commit.parents[0].id.__str__()}} href="{{ url_for(

                  'ui_ns.view_commit',

                  repo=repo.name,

                  username=username,

                  namespace=repo.namespace,

-                 commitid=commit.parents[0].oid.hex) }}">parent</a>

+                 commitid=commit.parents[0].id.__str__()) }}">parent</a>

                {% elif commit.parents|length > 1 %}

                <div class="btn-group" role="group">

                  <button id="parentsDrop" type="button" class="btn btn-secondary btn-sm dropdown-toggle"
@@ -88,8 +88,8 @@ 

                          repo=repo.name,

                          username=username,

                          namespace=repo.namespace,

-                         commitid=parent.oid.hex)

-                     }}" class="commitid">{{parent.oid.hex}}</a>

+                         commitid=parent.id.__str__())

+                     }}" class="commitid">{{parent.id.__str__()}}</a>

                    {% endfor %}

                  </div>

                </div>

file modified
+12 -12
@@ -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">

                        <strong>{{ diff_commit_full.message.split('\n')[0] }}</strong>

                      </a>
@@ -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">

-                         <code>{{ diff_commit_full.hex|short }}</code>

+                         <code>{{ diff_commit_full.id.__str__()|short }}</code>

                        </a>

                        <a class="btn btn-outline-primary font-weight-bold" href="{{ url_for(

                          'ui_ns.view_tree', username=username, namespace=repo.namespace,

-                         repo=repo.name, identifier=diff_commit_full.hex) }}"><span class="fa fa-file-code-o fa-fw"></span></a>

+                         repo=repo.name, identifier=diff_commit_full.id.__str__()) }}"><span class="fa fa-file-code-o fa-fw"></span></a>

                      </div>

                    </div>

                  </div>
@@ -146,10 +146,10 @@ 

  

  

                {% for commit in last_commits %}

-               <div class="list-group-item {{'ml-4' if diff_commits and commit.oid.hex in diff_commits}}"

-                    id="c_{{ commit.hex }}">

+               <div class="list-group-item {{'ml-4' if diff_commits and commit.id.__str__() in diff_commits}}"

+                    id="c_{{ commit.id.__str__() }}">

                  <div class="row align-items-center">

-                     {% if diff_commits and commit.oid.hex in diff_commits %}

+                     {% if diff_commits and commit.id.__str__() in diff_commits %}

                      <div class="new_commit" title="This commit is not in the main branch of this Repo">

                        <span class="fa fa-arrow-circle-right text-muted pl-1"></span>

                      </div>
@@ -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">

                        <strong>{{ commit.message.split('\n')[0] }}</strong>

                      </a>
@@ -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 }}">

-                         <code>{{ commit.hex|short }}</code>

+                         commitid=commit.id.__str__(), branch=branchname) }}"

+                         class="btn btn-outline-primary font-weight-bold commithash" id="c_{{ commit.id.__str__() }}">

+                         <code>{{ commit.id.__str__()|short }}</code>

                        </a>

                        <a class="btn btn-outline-primary font-weight-bold" href="{{ url_for(

                          'ui_ns.view_tree', username=username, namespace=repo.namespace,

-                         repo=repo.name, identifier=commit.hex) }}"><span class="fa fa-file-code-o fa-fw"></span></a>

+                         repo=repo.name, identifier=commit.id.__str__()) }}"><span class="fa fa-file-code-o fa-fw"></span></a>

                      </div>

                    </div>

                  </div>

@@ -101,14 +101,14 @@ 

            <div class="list-group my-2">

                {% for line in log %}

                {% set commit = g.repo_obj[line[0]] %}

-               <div class="list-group-item " id="c_{{ commit.hex }}">

+               <div class="list-group-item " id="c_{{ commit.id.__str__() }}">

                  <div class="row align-items-center">

                    <div class="col">

                      <a href="{{ url_for('ui_ns.view_commit',

                        repo=repo.name,

                        username=username,

                        namespace=repo.namespace,

-                       commitid=commit.hex, branch=branchname) }}"

+                       commitid=commit.id.__str__(), branch=branchname) }}"

                        class="notblue">

                        <strong>{{ commit.message.split('\n')[0] }}</strong>

                      </a>
@@ -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 }}">

-                         <code>{{ commit.hex|short }}</code>

+                         commitid=commit.id.__str__(), branch=branchname) }}"

+                         class="btn btn-outline-primary font-weight-bold commithash" id="c_{{ commit.id.__str__() }}">

+                         <code>{{ commit.id.__str__()|short }}</code>

                        </a>

                        <a class="btn btn-outline-primary font-weight-bold" href="{{ url_for(

                          'ui_ns.view_tree', username=username, namespace=repo.namespace,

-                         repo=repo.name, identifier=commit.hex) }}"><span class="fa fa-file-code-o fa-fw"></span></a>

+                         repo=repo.name, identifier=commit.id.__str__()) }}"><span class="fa fa-file-code-o fa-fw"></span></a>

                      </div>

                    </div>

                  </div>

@@ -61,7 +61,7 @@ 

                      repo=repo.name,

                      username=username,

                      namespace=repo.namespace,

-                     identifier=tag['object'].oid) }}"

+                     identifier=tag['object'].id) }}"

                      class="font-weight-bold">

                      <i class="fa fa-fw fa-tags text-muted"></i> {{tag['tagname']}}

                      </a>
@@ -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">

-               <code class="font-weight-bold">{{ tag['object'].oid | short }}</code>

+               <code class="font-weight-bold">{{ tag['object'].id | short }}</code>

              </a>

              <div class="btn-group">

                <a class="btn btn-outline-primary"
@@ -87,7 +87,7 @@ 

                         repo=repo.name,

                         username=username,

                         namespace=repo.namespace,

-                        identifier=tag['object'].oid) }}"

+                        identifier=tag['object'].id) }}"

                  title="view code tree for this release">

                  <i class="fa fa-fw fa-file-code-o"></i>

                </a>

@@ -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 %}

          <div class="list-group-item text-center bg-light" id="show_hidden_commits">
@@ -104,7 +104,7 @@ 

                <div class="btn-group">

                  <a href="{{ commit_link }}"

                    class="btn btn-outline-primary font-weight-bold {{'disabled' if not commit_link}}">

-                   <code>{{ commit.hex|short }}</code>

+                   <code>{{ commit.id.__str__()|short }}</code>

                  </a>

                  <a class="btn btn-outline-primary font-weight-bold {{'disabled' if not commit_link}}" href="{{tree_link}}"><span class="fa fa-file-code-o fa-fw"></span></a>

                </div>

@@ -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">

                            <code class="py-1 px-2 font-weight-bold commit_branch">{{ branchname }}</code><code

-                            class="py-1 px-2 font-weight-bold commit_hash">{{ commit.hex|short }}</code>

+                            class="py-1 px-2 font-weight-bold commit_hash">{{ commit.id.__str__()|short }}</code>

                            <span class="font-weight-bold">{{ commit.message.split('\n')[0] }}</span>

                          </a>

                        </div>

@@ -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__()) %}

  

              <div class="list-group-item">

              <div class="row align-items-center">
@@ -299,7 +299,7 @@ 

                    <div class="btn-group">

                      <a href="{{ commit_link }}"

                        class="btn btn-outline-primary font-weight-bold {{'disabled' if not commit_link}}">

-                       <code>{{ commit.hex|short }}</code>

+                       <code>{{ commit.id.__str__()|short }}</code>

                      </a>

                      <a class="btn btn-outline-primary font-weight-bold {{'disabled' if not commit_link}}" href="{{tree_link}}"><span class="fa fa-file-code-o fa-fw"></span></a>

                    </div>

@@ -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 %}

              <div class="list-group-item">

              <div class="row align-items-center">
@@ -350,9 +350,9 @@ 

                <div class="col-xs-auto pr-3 text-right">

                    <div class="btn-group">

                      <a href="{{ commit_link }}"

-                       data-commithash="{{ commit.hex }}"

+                       data-commithash="{{ commit.id.__str__() }}"

                        class="btn btn-outline-primary font-weight-bold {{'disabled' if not commit_link}} commithash">

-                       <code>{{ commit.hex|short }}</code>

+                       <code>{{ commit.id.__str__()|short }}</code>

                      </a>

                      <a class="btn btn-outline-primary font-weight-bold {{'disabled' if not commit_link}}" href="{{tree_link}}"><span class="fa fa-file-code-o fa-fw"></span></a>

                    </div>

file modified
+1 -1
@@ -149,7 +149,7 @@ 

  

      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):

file modified
+11 -11
@@ -279,7 +279,7 @@ 

          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 @@ 

          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 @@ 

      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 @@ 

          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 @@ 

                          )

  

              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 @@ 

              )

              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 @@ 

                          )

  

              if orig_commit:

-                 orig_commit = orig_commit.oid.hex

+                 orig_commit = str(orig_commit.id)

  

              parent = repo

              if repo.parent:

file modified
+1 -1
@@ -1508,7 +1508,7 @@ 

          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")

file modified
+21 -21
@@ -209,7 +209,7 @@ 

          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 @@ 

  

          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 @@ 

          # 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 @@ 

      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 @@ 

              )

  

              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 @@ 

      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 @@ 

      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 @@ 

          )

          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 @@ 

          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 @@ 

          _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 @@ 

                  repo=repo.name,

                  username=username,

                  namespace=repo.namespace,

-                 commitid=commit.hex,

+                 commitid=str(commit.id),

              )

          )

  
@@ -1057,7 +1057,7 @@ 

          # 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 @@ 

              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 @@ 

          archive_folder,

          flask.g.repo.fullname,

          tag_path,

-         commit.oid.hex,

+         str(commit.id),

          "%s.%s" % (name, extension),

      )

      headers = {
@@ -3563,7 +3563,7 @@ 

          repo,

          namespace=namespace,

          username=username,

-         commit=commit.oid.hex,

+         commit=str(commit.id),

          tag=tag_filename,

          name=name,

          archive_fmt=extension,

file modified
+2 -2
@@ -433,12 +433,12 @@ 

                          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

file modified
+1 -1
@@ -22,7 +22,7 @@ 

  munch <= 2.5.0

  Pillow <= 10.3.0

  psutil <= 5.9.8

- pygit2 < 1.15.0

+ pygit2 < 1.17.0

  python3-openid <= 3.2.0

  python-openid-cla == 1.2

  python-openid-teams == 1.1

file modified
+9 -9
@@ -757,13 +757,13 @@ 

      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 @@ 

      )

  

      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 @@ 

  

      if extra_commit:

          if commit:

-             parents = [commit.hex]

+             parents = [str(commit)]

  

          # Create another file in that git repo

          with open(os.path.join(newfolder, "test"), "w") as stream:
@@ -954,13 +954,13 @@ 

          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 @@ 

      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 @@ 

          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]

@@ -87,8 +87,8 @@ 

          tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0)

          repo.create_tag(

              "0.0.1",

-             first_commit.oid.hex,

-             pygit2.GIT_OBJ_COMMIT,

+             str(first_commit.id),

+             pygit2.enums.ObjectType.COMMIT,

              tagger,

              "Release 0.0.1",

          )
@@ -2614,7 +2614,7 @@ 

          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 @@ 

              "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 @@ 

              "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 @@ 

              "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 @@ 

              "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 @@ 

              "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 @@ 

              "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 @@ 

              "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 @@ 

                          "milestones": {},

                      },

                      "flag": {

-                         "commit_hash": commit.oid.hex,

+                         "commit_hash": str(commit.id),

                          "username": "Jenkins",

                          "percent": "0",

                          "comment": "Tests running",
@@ -2941,7 +2941,7 @@ 

              )

          ):

              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 @@ 

          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 @@ 

                          "milestones": {},

                      },

                      "flag": {

-                         "commit_hash": commit.oid.hex,

+                         "commit_hash": str(commit.id),

                          "username": "Jenkins",

                          "percent": "100",

                          "comment": "Tests passed",
@@ -3048,7 +3048,7 @@ 

              )

          ):

              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 @@ 

          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 @@ 

              "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 @@ 

          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 @@ 

          }

  

          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 @@ 

          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 @@ 

  

          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 @@ 

              "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 @@ 

          # 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 @@ 

          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 @@ 

          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 @@ 

          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 @@ 

          )

          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 @@ 

      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 @@ 

              "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])],

+             "tree_id": str(self.commit.tree_id),

          }

  

          self.assertEqual(data, expected_output)
@@ -4923,7 +4923,7 @@ 

      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 @@ 

              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 @@ 

              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 @@ 

              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,

              },

@@ -87,7 +87,7 @@ 

          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 @@ 

          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 @@ 

          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 @@ 

              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 @@ 

          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 @@ 

          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 @@ 

          # 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 @@ 

          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 @@ 

          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 @@ 

          # 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 @@ 

          # 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 @@ 

              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)

@@ -242,7 +242,7 @@ 

          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 @@ 

                  "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 @@ 

          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 @@ 

                  "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 @@ 

          tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0)

          tag = repo.create_tag(

              "v1.0_tag",

-             commit.oid.hex,

-             pygit2.GIT_OBJ_COMMIT,

+             str(commit.id),

+             pygit2.enums.ObjectType.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 @@ 

                  "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",

@@ -324,7 +324,7 @@ 

                  # 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 @@ 

                  # 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 @@ 

                  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,8 +1232,8 @@ 

          tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0)

          repo.create_tag(

              "0.0.1",

-             first_commit.oid.hex,

-             pygit2.GIT_OBJ_COMMIT,

+             str(first_commit.id),

+             pygit2.enums.ObjectType.COMMIT,

              tagger,

              "Release 0.0.1",

          )

@@ -481,7 +481,7 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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
@@ -2001,6 +2001,9 @@ 

              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 +2146,9 @@ 

              in [

                  {"results": "reference 'refs/heads/master' not found"},

                  {"results": "Reference 'refs/heads/master' not found"},

+                 {

+                     "results": "GitError(\"reference 'refs/heads/master' not found\")"

+                 },

              ]

          )

  

@@ -253,7 +253,7 @@ 

              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 <a href="/test/c/{orig_commit}"'

              self.assertIn(expected, output_text)

              repo = pagure.lib.query._get_project(self.session, "test")

@@ -980,11 +980,11 @@ 

          repo = pygit2.Repository(repopath)

          first_commit = repo.revparse_single("HEAD")

  

-         text = "Cf commit %s" % first_commit.oid.hex

+         text = "Cf commit %s" % str(first_commit.id)

          exp = (

              '<div class="markdown"><p>Cf commit <a href="/test/c/{0}" title="Commit {0}">{1}'

              "</a></p></div>".format(

-                 first_commit.oid.hex, first_commit.oid.hex[:7]

+                 str(first_commit.id), str(first_commit.id)[:7]

              )

          )

  

@@ -152,7 +152,7 @@ 

              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 @@ 

          """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 @@ 

          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")},

@@ -95,7 +95,7 @@ 

  

      try:

          com = repo.revparse_single("HEAD")

-         prev_commit = [com.oid.hex]

+         prev_commit = [str(com.id)]

      except:

          prev_commit = []

  
@@ -145,7 +145,7 @@ 

              # 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 @@ 

              # 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 @@ 

              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 @@ 

          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 @@ 

              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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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 @@ 

              # 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"

@@ -91,7 +91,7 @@ 

  

          try:

              com = repo.revparse_single("HEAD")

-             prev_commit = [com.oid.hex]

+             prev_commit = [str(com.id)]

          except:

              prev_commit = []

  

@@ -72,7 +72,7 @@ 

          # 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 @@ 

          # binary string representing the tree object ID

          tree,

          # list of binary strings representing parents of the new commit

-         [commit.hex],

+         [str(commit)],

      )

  

  

@@ -65,7 +65,7 @@ 

          )

  

          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:

@@ -65,11 +65,11 @@ 

          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 @@ 

          )

  

          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 @@ 

  

          # 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 @@ 

  

          # 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 @@ 

          )

  

          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 @@ 

  

          # 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)

@@ -75,7 +75,7 @@ 

  

          try:

              com = repo.revparse_single("HEAD")

-             prev_commit = [com.oid.hex]

+             prev_commit = [str(com.id)]

          except:

              prev_commit = []

  
@@ -117,7 +117,7 @@ 

              # 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 @@ 

              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]
@@ -174,22 +174,18 @@ 

          # 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: "

-             '<a href="/login/?'

+             '<a href="/login/?',

+             "You should be redirected automatically to the target URL: "

+             '<a href="/login/?',

          )

-         if hasattr(werkzeug, "__version__"):

-             werkzeug_v = tuple(

-                 int(el) for el in werkzeug.__version__.split(".")

-             )

-             if werkzeug_v >= (2, 1, 2):

-                 expected_response = (

-                     "You should be redirected automatically to the target URL: "

-                     '<a href="/login/?'

-                 )

-         self.assertIn(

-             expected_response,

-             output.get_data(as_text=True),

+         self.assertTrue(

+             any(

+                 expected_response in output.get_data(as_text=True)

+                 for expected_response in expected_responses

+             ),

+             msg=output.get_data(as_text=True),

          )

  

      @patch("pagure.lib.notify.send_email", MagicMock(return_value=True))

@@ -2637,8 +2637,8 @@ 

          tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0)

          repo.create_tag(

              "0.0.1",

-             first_commit.oid.hex,

-             pygit2.GIT_OBJ_COMMIT,

+             str(first_commit.id),

+             pygit2.enums.ObjectType.COMMIT,

              tagger,

              "Release 0.0.1",

          )
@@ -2650,8 +2650,8 @@ 

          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("<title>Commits - test - Pagure</title>", output_text)

          self.assertEqual(output_text.count('<span id="commit-actions">'), 1)

  
@@ -2672,7 +2672,7 @@ 

              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,8 +2690,8 @@ 

          tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0)

          repo.create_tag(

              "0.0.1",

-             first_commit.oid.hex,

-             pygit2.GIT_OBJ_COMMIT,

+             str(first_commit.id),

+             pygit2.enums.ObjectType.COMMIT,

              tagger,

              "Release 0.0.1",

          )
@@ -2700,8 +2700,8 @@ 

          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 @@ 

          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(

              "<title>Commit - test - %s - Pagure</title>" % commit_id,

              output_text,
@@ -2721,17 +2721,17 @@ 

          # 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(

                  "<title>Diff from %s to %s - test\n - Pagure</title>"

-                 % (c2.oid.hex, c1.oid.hex),

+                 % (str(c2.id), str(c1.id)),

                  output_text,

              )

              self.assertIn(

                  '        <span class="badge-light border border-secondary badge">%s</span>\n        ..\n        <span class="badge-light border border-secondary badge">%s</span>\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 @@ 

                  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(

                  "<title>Diff from %s to %s - test\n - Pagure</title>"

-                 % (c1.oid.hex, c2.oid.hex),

+                 % (str(c1.id), str(c2.id)),

                  output_text,

              )

              self.assertNotIn('id="show_hidden_commits"', output_text)

              self.assertIn(

                  '        <span class="badge-light border border-secondary badge">%s</span>\n        ..\n        <span class="badge-light border border-secondary badge">%s</span>\n'

-                 % (c1.oid.hex, c2.oid.hex),

+                 % (str(c1.id), str(c2.id)),

                  output_text,

              )

              self.assertIn(
@@ -2761,17 +2761,17 @@ 

  

          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(

                  "<title>Diff from %s to %s - test\n - Pagure</title>"

-                 % (c1.oid.hex, c3.oid.hex),

+                 % (str(c1.id), str(c3.id)),

                  output_text,

              )

              self.assertIn(

                  '        <span class="badge-light border border-secondary badge">%s</span>\n        ..\n        <span class="badge-light border border-secondary badge">%s</span>\n'

-                 % (c1.oid.hex, c3.oid.hex),

+                 % (str(c1.id), str(c3.id)),

                  output_text,

              )

              self.assertIn(
@@ -2795,17 +2795,17 @@ 

              )

  

              # 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(

                  "<title>Diff from %s to %s - test\n - Pagure</title>"

-                 % (c3.oid.hex, c1.oid.hex),

+                 % (str(c3.id), str(c1.id)),

                  output_text,

              )

              self.assertIn(

                  '        <span class="badge-light border border-secondary badge">%s</span>\n        ..\n        <span class="badge-light border border-secondary badge">%s</span>\n'

-                 % (c3.oid.hex, c1.oid.hex),

+                 % (str(c3.id), str(c1.id)),

                  output_text,

              )

              self.assertIn(
@@ -2830,13 +2830,13 @@ 

              # 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(

                  "<title>Diff from %s to %s - test\n - Pagure</title>"

-                 % (c3.oid.hex, c4.oid.hex),

+                 % (str(c3.id), str(c4.id)),

                  output_text,

              )

              self.assertIn(
@@ -2970,7 +2970,7 @@ 

          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"<html", output.data)

  
@@ -3175,7 +3175,7 @@ 

          repo = pygit2.Repository(os.path.join(self.path, "repos", "test.git"))

          commit = repo.revparse_single("HEAD")

  

-         output = self.app.get("/test/raw/%s/f/test.jpg" % commit.oid.hex)

+         output = self.app.get("/test/raw/%s/f/test.jpg" % str(commit.id))

          self.assertEqual(output.status_code, 200)

          output_text = output.get_data()

          self.assertTrue(output_text.startswith(b"\x00\x00\x01\x00"))
@@ -3219,7 +3219,7 @@ 

              output_text.startswith("diff --git a/test_binary b/test_binary\n")

          )

  

-         output = self.app.get("/test/raw/%s" % commit.oid.hex)

+         output = self.app.get("/test/raw/%s" % str(commit.id))

          self.assertEqual(output.status_code, 200)

          output_text = output.get_data(as_text=True)

          self.assertTrue(
@@ -3281,7 +3281,7 @@ 

          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)
@@ -3295,7 +3295,7 @@ 

  

          # View first commit - with the old URL scheme disabled - default

          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)

          output_text = output.get_data(as_text=True)
@@ -3318,7 +3318,7 @@ 

          commit_sl = repo.revparse_single("HEAD")

  

          # View another 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)
@@ -3326,7 +3326,7 @@ 

          self.assertIn("Committed by Cecil Committer", output_text)

  

          # Make sure that diff containing symlink displays the header correctly

-         output = self.app.get("/test/c/%s" % commit_sl.oid.hex)

+         output = self.app.get("/test/c/%s" % str(commit_sl.id))

          self.assertEqual(output.status_code, 200)

          output_text = output.get_data(as_text=True)

          # check the link to the file
@@ -3336,7 +3336,7 @@ 

          self.assertIn(">+1</span>", 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(
@@ -3348,7 +3348,7 @@ 

          )

  

          # 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(
@@ -3381,11 +3381,11 @@ 

          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)
@@ -3394,7 +3394,7 @@ 

  

          # 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)
@@ -3403,7 +3403,7 @@ 

  

          # 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)
@@ -3418,7 +3418,7 @@ 

  

          # 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)
@@ -3457,7 +3457,7 @@ 

          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)
@@ -3501,7 +3501,7 @@ 

          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)
@@ -3541,7 +3541,7 @@ 

          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(
@@ -3581,7 +3581,7 @@ 

          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(
@@ -3625,11 +3625,11 @@ 

          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(
@@ -3683,7 +3683,7 @@ 

          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(
@@ -3749,7 +3749,7 @@ 

          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("<title>Tree - test - Pagure</title>", output_text)
@@ -4993,8 +4993,8 @@ 

          tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0)

          repo.create_tag(

              "0.0.1",

-             first_commit.oid.hex,

-             pygit2.GIT_OBJ_COMMIT,

+             str(first_commit.id),

+             pygit2.enums.ObjectType.COMMIT,

              tagger,

              "Release 0.0.1",

          )

@@ -44,10 +44,10 @@ 

          """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(

-             "<title>Commit - test - %s - Pagure</title>" % self.commit.oid.hex,

+             "<title>Commit - test - %s - Pagure</title>" % str(self.commit.id),

              output.get_data(as_text=True),

          )

          self.assertIn(
@@ -65,7 +65,7 @@ 

          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 @@ 

          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(

-             "<title>Commit - test - %s - Pagure</title>" % self.commit.oid.hex,

+             "<title>Commit - test - %s - Pagure</title>" % str(self.commit.id),

              output_text,

          )

          self.assertIn("#commit-overview-collapse", output_text)
@@ -110,7 +110,7 @@ 

          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 @@ 

          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(

-             "<title>Commit - test - %s - Pagure</title>" % self.commit.oid.hex,

+             "<title>Commit - test - %s - Pagure</title>" % str(self.commit.id),

              output_text,

          )

          self.assertIn("#commit-overview-collapse", output_text)
@@ -155,7 +155,7 @@ 

          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 @@ 

          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(

-             "<title>Commit - test - %s - Pagure</title>" % self.commit.oid.hex,

+             "<title>Commit - test - %s - Pagure</title>" % str(self.commit.id),

              output_text,

          )

          self.assertIn("#commit-overview-collapse", output_text)
@@ -200,7 +200,7 @@ 

          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 @@ 

          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(

-             "<title>Commit - test - %s - Pagure</title>" % self.commit.oid.hex,

+             "<title>Commit - test - %s - Pagure</title>" % str(self.commit.id),

              output_text,

          )

          self.assertIn("#commit-overview-collapse", output_text)
@@ -244,7 +244,7 @@ 

          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 @@ 

          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(

-             "<title>Commit - test - %s - Pagure</title>" % self.commit.oid.hex,

+             "<title>Commit - test - %s - Pagure</title>" % str(self.commit.id),

              output_text,

          )

          self.assertIn("#commit-overview-collapse", output_text)
@@ -297,7 +297,7 @@ 

          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 @@ 

          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(

-             "<title>Commit - test - %s - Pagure</title>" % self.commit.oid.hex,

+             "<title>Commit - test - %s - Pagure</title>" % str(self.commit.id),

              output_text,

          )

          self.assertIn("#commit-overview-collapse", output_text)

@@ -236,7 +236,7 @@ 

          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)

@@ -135,7 +135,7 @@ 

              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,10 +182,14 @@ 

              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"

+             "v1.0",

+             parent,

+             pygit2.enums.ObjectType.COMMIT,

+             tagger,

+             "Release v1.0",

          )

  

          output = self.app.get("/test/blame/sources?identifier=v1.0")
@@ -217,7 +221,7 @@ 

          )

  

          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)

@@ -144,7 +144,7 @@ 

          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"<html", output.data)

  

@@ -113,7 +113,7 @@ 

              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/history/sources?identifier={}".format(parent)
@@ -140,10 +140,14 @@ 

              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"

+             "v1.0",

+             parent,

+             pygit2.enums.ObjectType.COMMIT,

+             tagger,

+             "Release v1.0",

          )

  

          output = self.app.get("/test/history/sources?identifier=v1.0")

@@ -68,7 +68,7 @@ 

          PagureRepo.push(ori_remote, refname)

  

          master_branch = clone_repo.lookup_branch("master")

-         first_commit = master_branch.peel().hex

+         first_commit = str(master_branch.peel().id)

  

          # Second commit

          with open(os.path.join(repopath, ".gitignore"), "w") as stream:

file modified
+3 -3
@@ -2361,8 +2361,8 @@ 

          tests.add_content_git_repo(gitrepo, "master")

  

          # Add a tag

-         tagged_commit = (

-             pygit2.Repository(gitrepo).revparse_single("master").hex

+         tagged_commit = str(

+             pygit2.Repository(gitrepo).revparse_single("master").id

          )

          tag_sha = tests.add_tag_git_repo(

              gitrepo, "1.2.3", tagged_commit, "release 1.2.3"
@@ -2392,7 +2392,7 @@ 

          # Check the tag is there

          fork_obj = pygit2.Repository(project.repopath("main"))

          tag = fork_obj.get(tag_sha)

-         self.assertEqual(fork_obj[tag.target].hex, tagged_commit)

+         self.assertEqual(str(fork_obj[tag.target].id), tagged_commit)

          self.assertEqual(tag.message, "release 1.2.3")

  

      def test_fork_project_namespaced(self):

file modified
+10 -10
@@ -1851,9 +1851,9 @@ 

          shutil.rmtree(newgitrepo)

  

          output4 = pagure.lib.git.get_revs_between(

-             "0", branch_commit.oid.hex, gitrepo, "refs/heads/feature"

+             "0", str(branch_commit.id), gitrepo, "refs/heads/feature"

          )

-         self.assertEqual(output4, [branch_commit.oid.hex])

+         self.assertEqual(output4, [str(branch_commit.id)])

  

      def test_get_author(self):

          """Test the get_author method of pagure.lib.git."""
@@ -2284,18 +2284,18 @@ 

  

          # make sure that creating works the first time

          pagure.lib.git.update_pull_ref(fake_pr, fork)

-         oldhex = fork.references["refs/heads/master"].peel().hex

+         oldhex = str(fork.references["refs/heads/master"].peel().id)

          self.assertEqual(

-             orig.references["refs/pull/6/head"].peel().hex, oldhex

+             str(orig.references["refs/pull/6/head"].peel().id), oldhex

          )

  

          # make sure that updating works correctly

          tests.add_content_git_repo(projects[1], append="foobar")

-         newhex = fork.references["refs/heads/master"].peel().hex

+         newhex = str(fork.references["refs/heads/master"].peel().id)

          self.assertNotEqual(oldhex, newhex)

          pagure.lib.git.update_pull_ref(fake_pr, fork)

          self.assertEqual(

-             orig.references["refs/pull/6/head"].peel().hex, newhex

+             str(orig.references["refs/pull/6/head"].peel().id), newhex

          )

  

          # make sure the function works fine even if there's a leftover
@@ -2308,11 +2308,11 @@ 

                  pagure.lib.git.update_pull_ref(fake_pr, fork)

          self.assertIsNotNone(fork.remotes["pingou_1234567"])

          tests.add_content_git_repo(projects[1], append="foobarbaz")

-         newesthex = fork.references["refs/heads/master"].peel().hex

+         newesthex = str(fork.references["refs/heads/master"].peel().id)

          self.assertNotEqual(newhex, newesthex)

          pagure.lib.git.update_pull_ref(fake_pr, fork)

          self.assertEqual(

-             orig.references["refs/pull/6/head"].peel().hex, newesthex

+             str(orig.references["refs/pull/6/head"].peel().id), newesthex

          )

  

  
@@ -2372,7 +2372,7 @@ 

              # binary string representing the tree object ID

              tree,

              # list of binary strings representing parents of the new commit

-             [self.first_commit.oid.hex],

+             [str(self.first_commit.id)],

          )

  

          self.second_commit = repo.revparse_single("HEAD")
@@ -2386,7 +2386,7 @@ 

              # binary string representing the tree object ID

              tree,

              # list of binary strings representing parents of the new commit

-             [self.second_commit.oid.hex],

+             [str(self.second_commit.id)],

          )

  

          self.third_commit = repo.revparse_single("HEAD")

@@ -98,7 +98,7 @@ 

              parents = []

              try:

                  last_commit = clone_repo.revparse_single("HEAD")

-                 parents = [last_commit.oid.hex]

+                 parents = [str(last_commit.id)]

              except KeyError:

                  pass

  
@@ -151,7 +151,7 @@ 

                  # 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 main repo

          refname = "refs/heads/master:refs/heads/master"
@@ -181,7 +181,7 @@ 

              # 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)],

          )

  

          with open(os.path.join(repopath, "sources"), "w") as stream:
@@ -201,7 +201,7 @@ 

              # binary string representing the tree object ID

              tree,

              # list of binary strings representing parents of the new commit

-             [last_commit.hex],

+             [str(last_commit)],

          )

  

          # Push to the fork repo
@@ -320,7 +320,7 @@ 

  

          pr_ref = repo.lookup_reference("refs/pull/1/head")

          commit = pr_ref.peel()

-         self.assertEqual(commit.oid.hex, diff_commits[0].oid.hex)

+         self.assertEqual(str(commit.id), str(diff_commits[0].id))

  

      @patch.dict(

          "pagure.config.config", {"FEDORA_MESSAGING_NOTIFICATIONS": True}
@@ -359,7 +359,7 @@ 

  

          pr_ref = repo.lookup_reference("refs/pull/1/head")

          commit = pr_ref.peel()

-         self.assertEqual(commit.oid.hex, diff_commits[0].oid.hex)

+         self.assertEqual(str(commit.id), str(diff_commits[0].id))

  

          # Add a new commit on the fork

          repopath = os.path.join(self.path, "pingou_test2")
@@ -386,7 +386,7 @@ 

              # 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
@@ -754,8 +754,8 @@ 

  

          pr_ref = repo.lookup_reference("refs/pull/1/head")

          commit2 = pr_ref.peel()

-         self.assertEqual(commit2.oid.hex, diff_commits[0].oid.hex)

-         self.assertNotEqual(commit.oid.hex, commit2.oid.hex)

+         self.assertEqual(str(commit2.id), str(diff_commits[0].id))

+         self.assertNotEqual(str(commit.id), str(commit2.id))

  

      def test_two_diff_pull_request_sequentially(self):

          """Test calling pagure.lib.git.diff_pull_request twice returns
@@ -791,7 +791,7 @@ 

  

          pr_ref = repo.lookup_reference("refs/pull/1/head")

          commit = pr_ref.peel()

-         self.assertEqual(commit.oid.hex, diff_commits[0].oid.hex)

+         self.assertEqual(str(commit.id), str(diff_commits[0].id))

  

          # Run diff_pull_request a second time

  
@@ -804,8 +804,8 @@ 

          )

          self.assertEqual(len(diff_commits2), 2)

          self.assertEqual(

-             [d.oid.hex for d in diff_commits2],

-             [d.oid.hex for d in diff_commits],

+             [str(d.id) for d in diff_commits2],

+             [str(d.id) for d in diff_commits],

          )

  

          # Check that the PR has its PR refs
@@ -818,9 +818,9 @@ 

  

          pr_ref = repo.lookup_reference("refs/pull/1/head")

          commit2 = pr_ref.peel()

-         self.assertEqual(commit2.oid.hex, diff_commits[0].oid.hex)

+         self.assertEqual(str(commit2.id), str(diff_commits[0].id))

  

-         self.assertEqual(commit.oid.hex, commit2.oid.hex)

+         self.assertEqual(str(commit.id), str(commit2.id))

  

  

  if __name__ == "__main__":

@@ -45,8 +45,8 @@ 

          tagger = pygit2.Signature("Alice Doe", "adoe@example.com", 12347, 0)

          repo.create_tag(

              tag,

-             first_commit.oid.hex,

-             pygit2.GIT_OBJ_COMMIT,

+             str(first_commit.id),

+             pygit2.enums.ObjectType.COMMIT,

              tagger,

              "Release " + tag,

          )

@@ -852,7 +852,7 @@ 

          )

  

          commits = [

-             commit.oid.hex

+             str(commit.id)

              for commit in self.repo_obj.walk(

                  self.repo_obj.head.target, pygit2.GIT_SORT_NONE

              )

@@ -39,8 +39,8 @@ 

          tests.add_content_git_repo(self.projects[0], extra_commit=True)

          repo = pygit2.Repository(self.projects[0])

          commit = repo.references["refs/heads/master"].peel()

-         sha = commit.hex

-         history = [c.hex for c in repo.walk(sha)]

+         sha = str(commit.id)

+         history = [str(c.id) for c in repo.walk(sha)]

          project = pagure.lib.query.get_authorized_project(self.session, "test")

          return project, sha, history

  

Test results in Debian unstable (pygit2 1.16.0, full version list near the top, the failures are a lack of openssh-client)
https://salsa.debian.org/debian/pagure/-/jobs/6982015/raw
https://salsa.debian.org/debian/pagure/-/jobs/6982017/raw

The templates use .__str__() because str() does not work there.

1 new commit added

  • more id fixup
5 months ago

1 new commit added

  • more id fixup
5 months ago

1 new commit added

  • fix(pip): Pin pygit2 version < 1.17
5 months ago

The CI test failures were partly actual bugs that I have now fixed
(Debian skips some tests because we don't have
pagure_messages/fedora_messaging), and partly that this is only enough
to pass all tests with pygit2 1.16, not 1.17.

There's only 1-2 new failures with pygit2 1.17, and I plan to try fixing
them, but I have added a pygit2 < 1.17 pin for now so they do not need
to block merging this.

Metadata
Changes Summary 51
+2 -2
file changed
dev-data.py
+8 -8
file changed
pagure/api/fork.py
+4 -4
file changed
pagure/api/project.py
+3 -3
file changed
pagure/docs_server.py
+6 -6
file changed
pagure/hooks/files/git_multimail_upstream.py
+7 -7
file changed
pagure/internal/__init__.py
+44 -46
file changed
pagure/lib/git.py
+3 -3
file changed
pagure/lib/model.py
+3 -3
file changed
pagure/lib/tasks.py
+4 -4
file changed
pagure/templates/commit.html
+12 -12
file changed
pagure/templates/commits.html
+6 -6
file changed
pagure/templates/file_history.html
+4 -4
file changed
pagure/templates/releases.html
+5 -5
file changed
pagure/templates/repo_comparecommits.html
+2 -2
file changed
pagure/templates/repo_info.html
+3 -3
file changed
pagure/templates/repo_new_pull_request.html
+6 -6
file changed
pagure/templates/repo_pull_request.html
+1 -1
file changed
pagure/ui/filters.py
+11 -11
file changed
pagure/ui/fork.py
+1 -1
file changed
pagure/ui/issues.py
+21 -21
file changed
pagure/ui/repo.py
+2 -2
file changed
pagure/utils.py
+1 -1
file changed
requirements.txt
+9 -9
file changed
tests/__init__.py
+46 -46
file changed
tests/test_pagure_flask_api_project.py
+12 -12
file changed
tests/test_pagure_flask_api_project_git_tags.py
+8 -8
file changed
tests/test_pagure_flask_api_project_view_file.py
+5 -5
file changed
tests/test_pagure_flask_api_ui_private_repo.py
+24 -18
file changed
tests/test_pagure_flask_internal.py
+1 -1
file changed
tests/test_pagure_flask_rebase.py
+2 -2
file changed
tests/test_pagure_flask_ui_app.py
+3 -3
file changed
tests/test_pagure_flask_ui_archives.py
+10 -10
file changed
tests/test_pagure_flask_ui_fork.py
+1 -1
file changed
tests/test_pagure_flask_ui_issue_pr_link.py
+2 -2
file changed
tests/test_pagure_flask_ui_issues_templates.py
+1 -1
file changed
tests/test_pagure_flask_ui_no_master_branch.py
+10 -10
file changed
tests/test_pagure_flask_ui_old_commit.py
+13 -17
file changed
tests/test_pagure_flask_ui_remote_pr.py
+48 -48
file changed
tests/test_pagure_flask_ui_repo.py
+20 -20
file changed
tests/test_pagure_flask_ui_repo_flag_commit.py
+1 -1
file changed
tests/test_pagure_flask_ui_repo_slash_name.py
+8 -4
file changed
tests/test_pagure_flask_ui_repo_view_blame.py
+1 -1
file changed
tests/test_pagure_flask_ui_repo_view_file.py
+7 -3
file changed
tests/test_pagure_flask_ui_repo_view_history.py
+1 -1
file changed
tests/test_pagure_flask_ui_slash_branch_name.py
+3 -3
file changed
tests/test_pagure_lib.py
+10 -10
file changed
tests/test_pagure_lib_git.py
+14 -14
file changed
tests/test_pagure_lib_git_diff_pr.py
+2 -2
file changed
tests/test_pagure_lib_git_get_tags_objects.py
+1 -1
file changed
tests/test_pagure_lib_task_services.py
+2 -2
file changed
tests/test_pagure_send_notification.py