Skip to content

Conversation

@hsbt
Copy link
Member

@hsbt hsbt commented Dec 10, 2025

What was the end-user or developer problem that led to this PR?

I forgot to exclude released PRs from backport targets.

What is your fix for the problem, implemented in this PR?

Pick released PRs from commit log like:

❯ git log --oneline --grep "^Merge pull request #" v4.0.0..4.0
78bd794db8 (origin/4.0, 4.0) Merge pull request #9173 from ruby/release/4.0.1
165e7ebb88 Merge pull request #9169 from Shopify/ec-fix-clean
...
6ecf058112 Merge pull request #9152 from ruby/suppress-git-message
eea05a2510 Merge pull request #9150 from ruby/release/4.0.0

and scan #XXXX numbers. We already picked PR numbers from master branch for backporting targets. Now, we can select only #9178 in this time.

Make sure the following tasks are checked

Copilot AI review requested due to automatic review settings December 10, 2025 07:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds logic to exclude already-released pull requests from backport targets when preparing patch releases on stable branches. The implementation scans the stable branch's commit log to identify PRs that have already been released and filters them out from the unreleased PR list.

  • Adds released_pull_requests method to extract PR numbers from stable branch commits
  • Updates unreleased_pr_ids to filter out released PRs during patch releases
  • Changes block syntax for processing PR numbers from {...} to do...end

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

tool/release.rb Outdated
result.split("\n").each {|pr_number| pr_ids.add(pr_number.to_i) }
result.split("\n").each do |pr_number|
pr_ids.add(pr_number.to_i)
if @level == :patch && released_pull_requests.include?(pr_number.to_i)
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The released_pull_requests method is called inside a loop for each PR number found (potentially hundreds of times), causing the git command to be executed repeatedly. This is very inefficient. Consider memoizing the result using ||= or moving the check outside the loop.

Suggested fix:

# In the released_pull_requests method definition (line 306-314):
def released_pull_requests
  @released_pull_requests ||= begin
    commits = `git log --oneline --grep "^Merge pull request #" #{@previous_release_tag}..#{@previous_stable_branch}`.split("\n")
    commits.filter_map do |commit|
      match = commit.match(/Merge pull request #(\d+) from /)
      match[1].to_i if match
    end
  end
end

Copilot uses AI. Check for mistakes.
@hsbt hsbt force-pushed the fixed-unreleased-prs branch from ce4a983 to 1111ad9 Compare December 10, 2025 08:20
@hsbt hsbt merged commit 7ad65b7 into master Dec 10, 2025
79 checks passed
@hsbt hsbt deleted the fixed-unreleased-prs branch December 10, 2025 09:08
hsbt added a commit that referenced this pull request Dec 16, 2025
Exclude released PR on stable branch

(cherry picked from commit 7ad65b7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants