From b07c771d4640c4b4cacd1ea8952769565c4b5123 Mon Sep 17 00:00:00 2001 From: Doug Miller Date: Wed, 16 Dec 2020 16:40:43 -0600 Subject: [PATCH] Update #get_all_tags to only return tags that are for commits on the current branch --- Gemfile.lock | 1 + lib/github_changelog_generator/octo_fetcher.rb | 3 ++- spec/unit/octo_fetcher_spec.rb | 12 +++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ecade4e01..0d5583ad6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,6 +3,7 @@ PATH specs: github_changelog_generator (1.15.2) activesupport + async (>= 1.25.0) async-http-faraday faraday-http-cache multi_json diff --git a/lib/github_changelog_generator/octo_fetcher.rb b/lib/github_changelog_generator/octo_fetcher.rb index fb36b6aa4..4d9110b9c 100644 --- a/lib/github_changelog_generator/octo_fetcher.rb +++ b/lib/github_changelog_generator/octo_fetcher.rb @@ -98,7 +98,8 @@ def client def get_all_tags print "Fetching tags...\r" if @options[:verbose] - check_github_response { github_fetch_tags } + all_tags = check_github_response { github_fetch_tags } + all_tags.select { |tag| commits.any? { |commit| commit[:sha] == tag["commit"]["sha"] } } end # Returns the number of pages for a API call diff --git a/spec/unit/octo_fetcher_spec.rb b/spec/unit/octo_fetcher_spec.rb index f128872fc..d05079977 100644 --- a/spec/unit/octo_fetcher_spec.rb +++ b/spec/unit/octo_fetcher_spec.rb @@ -76,11 +76,17 @@ end describe "#get_all_tags" do + let(:in_branch_tags) { [{ "commit" => { "sha" => "in-branch" } }] } + let(:mock_tags) do + in_branch_tags + [{ "commit" => { "sha" => "off-branch" } }] + end + let(:mock_commits) { [{ sha: "in-branch" }] } + context "when github_fetch_tags returns tags" do - it "returns tags" do - mock_tags = ["tag"] + it "returns tags that are on the current branch" do allow(fetcher).to receive(:github_fetch_tags).and_return(mock_tags) - expect(fetcher.get_all_tags).to eq(mock_tags) + allow(fetcher).to receive(:commits).and_return(mock_commits) + expect(fetcher.get_all_tags).to eq(in_branch_tags) end end end pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy