Don't backport base commit of branch in the same branch (#20628)

This commit is contained in:
Ivan 2021-02-17 18:55:24 +03:00 committed by GitHub
parent d15bac31ff
commit 42c22475e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -62,7 +62,7 @@ class Backport:
RE_NO_BACKPORT = re.compile(r'^v(\d+\.\d+)-no-backport$')
RE_BACKPORTED = re.compile(r'^v(\d+\.\d+)-backported$')
# pull-requests are sorted by ancestry from the least recent.
# pull-requests are sorted by ancestry from the most recent.
for pr in pull_requests:
while repo.comparator(branches[-1][1]) >= repo.comparator(pr['mergeCommit']['oid']):
logging.info("PR #{} is already inside {}. Dropping this branch for further PRs".format(pr['number'], branches[-1][0]))

View File

@ -6,15 +6,15 @@ import os
import re
class RepositoryBase(object):
class RepositoryBase:
def __init__(self, repo_path):
import git
self._repo = git.Repo(repo_path, search_parent_directories=(not repo_path))
# commit comparator
# comparator of commits
def cmp(x, y):
if x == y:
if str(x) == str(y):
return 0
if self._repo.is_ancestor(x, y):
return -1