diff --git a/utils/github/backport.py b/utils/github/backport.py index d2687b893a4..589124324b1 100644 --- a/utils/github/backport.py +++ b/utils/github/backport.py @@ -25,24 +25,23 @@ class Backport: def getPullRequests(self, from_commit): return self._gh.get_pull_requests(from_commit) - def getBranchesWithLTS(self): - branches = [] - for pull_request in self._gh.find_pull_requests("release-lts"): + def getBranchesWithRelease(self): + branches = set() + for pull_request in self._gh.find_pull_requests("release"): if not pull_request['merged'] and not pull_request['closed']: - branches.append(pull_request['headRefName']) + branches.add(pull_request['headRefName']) return branches - def execute(self, repo, upstream, until_commit, number, run_cherrypick, find_lts=False): + def execute(self, repo, upstream, until_commit, run_cherrypick): repo = LocalRepo(repo, upstream, self.default_branch_name) all_branches = repo.get_release_branches() # [(branch_name, base_commit)] - last_branches = set([branch[0] for branch in all_branches[-number:]]) - lts_branches = set(self.getBranchesWithLTS() if find_lts else []) + release_branches = self.getBranchesWithRelease() branches = [] # iterate over all branches to preserve their precedence. for branch in all_branches: - if branch[0] in last_branches or branch[0] in lts_branches: + if branch[0] in release_branches: branches.append(branch) if not branches: @@ -115,8 +114,6 @@ if __name__ == "__main__": parser.add_argument('--token', type=str, required=True, help='token for Github access') parser.add_argument('--repo', type=str, required=True, help='path to full repository', metavar='PATH') parser.add_argument('--til', type=str, help='check PRs from HEAD til this commit', metavar='COMMIT') - parser.add_argument('-n', type=int, dest='number', help='number of last release branches to consider') - parser.add_argument('--lts', action='store_true', help='consider branches with LTS') parser.add_argument('--dry-run', action='store_true', help='do not create or merge any PRs', default=False) parser.add_argument('--verbose', '-v', action='store_true', help='more verbose output', default=False) parser.add_argument('--upstream', '-u', type=str, help='remote name of upstream in repository', default='origin') @@ -129,4 +126,4 @@ if __name__ == "__main__": cherrypick_run = lambda token, pr, branch: CherryPick(token, 'ClickHouse', 'ClickHouse', 'core', pr, branch).execute(args.repo, args.dry_run) bp = Backport(args.token, 'ClickHouse', 'ClickHouse', 'core') - bp.execute(args.repo, args.upstream, args.til, args.number, cherrypick_run, args.lts) + bp.execute(args.repo, args.upstream, args.til, cherrypick_run)