diff --git a/script/release/release.py b/script/release/release.py index d0545a7e6..e9a52c4aa 100755 --- a/script/release/release.py +++ b/script/release/release.py @@ -34,6 +34,15 @@ def create_initial_branch(repository, args): release_branch = repository.create_release_branch(args.release, args.base) if args.base and args.cherries: print('Detected patch version.') + auto_prs = repository.get_prs_in_milestone(args.release) + if auto_prs: + print( + 'Found the following PRs in this release\'s milestone: {}'.format(', '.join(auto_prs)) + ) + proceed = yesno('Automatically cherry-pick detected PRs? Y/n', default=True) + if proceed: + repository.cherry_pick_prs(release_branch, auto_prs) + cherries = input('Indicate (space-separated) PR numbers to cherry-pick then press Enter:\n') repository.cherry_pick_prs(release_branch, cherries.split()) diff --git a/script/release/release/repository.py b/script/release/release/repository.py index d4d1c7201..9a5d432c0 100644 --- a/script/release/release/repository.py +++ b/script/release/release/repository.py @@ -196,6 +196,24 @@ class Repository(object): f.flush() self.git_repo.git.am('--3way', f.name) + def get_prs_in_milestone(self, version): + milestones = self.gh_repo.get_milestones(state='open') + milestone = None + for ms in milestones: + if ms.title == version: + milestone = ms + break + if not milestone: + print('Didn\'t find a milestone matching "{}"'.format(version)) + return None + + issues = self.gh_repo.get_issues(milestone=milestone, state='all') + prs = [] + for issue in issues: + if issue.pull_request is not None: + prs.append(issue.number) + return sorted(prs) + def get_contributors(pr_data): commits = pr_data.get_commits()