From 3e68d3753fc57593118afde3ea7d9b4da878667f Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:53:41 +0000 Subject: [PATCH 1/3] Fix missing release branch when looking for commits --- lib/github_changelog_generator/octo_fetcher.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/github_changelog_generator/octo_fetcher.rb b/lib/github_changelog_generator/octo_fetcher.rb index 971c50aa..e6439aec 100644 --- a/lib/github_changelog_generator/octo_fetcher.rb +++ b/lib/github_changelog_generator/octo_fetcher.rb @@ -345,7 +345,7 @@ def default_branch # @param [String] name # @return [Array] def commits_in_branch(name) - @branches ||= client.branches(user_project).map { |branch| [branch[:name], branch] }.to_h + @branches ||= client.branches(user_project, DEFAULT_REQUEST_OPTIONS).map { |branch| [branch[:name], branch] }.to_h if (branch = @branches[name]) commits_in_tag(branch[:commit][:sha]) From c7f44ad816fb849f0078b5e4dea024480fdd37a9 Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Thu, 31 Oct 2024 13:45:44 +0000 Subject: [PATCH 2/3] Use iterate pages to handle unlimited branches --- lib/github_changelog_generator/octo_fetcher.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/github_changelog_generator/octo_fetcher.rb b/lib/github_changelog_generator/octo_fetcher.rb index e6439aec..ebc81790 100644 --- a/lib/github_changelog_generator/octo_fetcher.rb +++ b/lib/github_changelog_generator/octo_fetcher.rb @@ -345,7 +345,13 @@ def default_branch # @param [String] name # @return [Array] def commits_in_branch(name) - @branches ||= client.branches(user_project, DEFAULT_REQUEST_OPTIONS).map { |branch| [branch[:name], branch] }.to_h + @branches ||= lambda do + iterate_pages(client, "branches") do |branches| + branches_map = branches.map { |branch| [branch[:name], branch] }.to_h + return branches_map if branches_map[name] + end + return {} + end[] if (branch = @branches[name]) commits_in_tag(branch[:commit][:sha]) From efed80cb783b1b780773f4470d8616df16a9d463 Mon Sep 17 00:00:00 2001 From: "Steven B." <51370195+sdb9696@users.noreply.github.com> Date: Mon, 11 Nov 2024 09:22:05 +0000 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Olle Jonsson --- lib/github_changelog_generator/octo_fetcher.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/github_changelog_generator/octo_fetcher.rb b/lib/github_changelog_generator/octo_fetcher.rb index ebc81790..e060cde4 100644 --- a/lib/github_changelog_generator/octo_fetcher.rb +++ b/lib/github_changelog_generator/octo_fetcher.rb @@ -347,11 +347,11 @@ def default_branch def commits_in_branch(name) @branches ||= lambda do iterate_pages(client, "branches") do |branches| - branches_map = branches.map { |branch| [branch[:name], branch] }.to_h + branches_map = branches.to_h { |branch| [branch[:name], branch] } return branches_map if branches_map[name] end return {} - end[] + end.call if (branch = @branches[name]) commits_in_tag(branch[:commit][:sha])