Skip to content

Commit

Permalink
Merge branch 'main' into jamiemagee/terraform-sorbet-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulapopoola committed Apr 24, 2024
2 parents b7fd25f + 7fa81c6 commit 409e8ed
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 101 deletions.
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Expand Up @@ -19,6 +19,7 @@ on: # yamllint disable-line rule:truthy
branches: [ main ]
paths-ignore:
- '*/spec/fixtures/**'
- '*/helpers/test/*/fixtures/**'
- 'common/lib/dependabot.rb'
schedule:
- cron: '41 4 * * 3'
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/dependency-review.yml
@@ -1,5 +1,11 @@
name: Dependency Review
on: [pull_request] # yamllint disable-line rule:truthy
on: # yamllint disable-line rule:truthy
pull_request:
branches: [ main ]
paths-ignore:
- '*/spec/fixtures/**'
- '*/helpers/test/*/fixtures/**'
- 'common/lib/dependabot.rb'

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Expand Up @@ -303,7 +303,7 @@ GEM
rubocop-rspec_rails (~> 2.28)
rubocop-rspec_rails (2.28.3)
rubocop (~> 1.40)
rubocop-sorbet (0.8.1)
rubocop-sorbet (0.8.2)
rubocop (>= 0.90.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
Expand Down
13 changes: 3 additions & 10 deletions common/lib/dependabot/metadata_finders/base/changelog_finder.rb
Expand Up @@ -53,6 +53,8 @@ def initialize(source:, dependency:, credentials:,
@dependency = dependency
@credentials = credentials
@suggested_changelog_url = suggested_changelog_url
# strip fragment from URL, if present
@suggested_changelog_url = @suggested_changelog_url&.split("#")&.first

@new_version = T.let(nil, T.nilable(String))
@changelog_from_suggested_url = T.let(nil, T.untyped)
Expand Down Expand Up @@ -127,16 +129,7 @@ def changelog_from_suggested_url
suggested_source_client = github_client_for_source(T.must(suggested_source))
tmp_files = T.unsafe(suggested_source_client).contents(suggested_source&.repo, opts)

filename = T.must(T.must(suggested_changelog_url).split("/").last).split("#").first

# If the suggested source points to a specific directory
# then we will receive a hash for just the changelog file
if suggested_source&.directory && tmp_files[:name] == filename
return @changelog_from_suggested_url = tmp_files
end

# Otherwise we will get back an array of hashes representing the files
# in the root directory and we need to find the changelog
filename = T.must(T.must(suggested_changelog_url).split("/").last)
@changelog_from_suggested_url =
tmp_files.find { |f| f.name == filename }
rescue Octokit::NotFound, Octokit::UnavailableForLegalReasons
Expand Down
Expand Up @@ -158,60 +158,35 @@

context "when given a suggested_changelog_url" do
let(:suggested_changelog_url) do
"github.com/mperham/sidekiq/blob/master/Pro-Changes.md"
end

let(:source) do
Dependabot::Source.from_url(suggested_changelog_url)
"https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md"
end

let(:finder) do
described_class.new(
source: source,
source: nil,
credentials: credentials,
dependency: dependency,
suggested_changelog_url: suggested_changelog_url
)
end

context "and it points to a specific directory" do
let(:suggested_changelog_url) do
"github.com/mperham/sidekiq/blob/master/dir/Pro-Changes.md"
end

before do
sidekiq_changelog =
fixture("github", "contents_sidekiq_changelog.json")
suggested_github_url =
"https://api.github.com/repos/mperham/sidekiq/contents/dir?ref=master"
stub_request(:get, suggested_github_url)
.to_return(status: 200,
body: sidekiq_changelog,
headers: { "Content-Type" => "application/json" })
end
before do
stub_request(:get, "https://api.github.com/repos/mperham/sidekiq/contents/")
.to_return(status: 200,
body: fixture("github", "contents_sidekiq.json"),
headers: { "Content-Type" => "application/json" })
end

it "gets the right URL" do
expect(subject)
.to eq(
"https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md"
)
end
it "gets the right URL" do
expect(subject)
.to eq(
"https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md"
)
end

context "but it does not point to a specific directory" do
context "and the URL has a fragment" do
let(:suggested_changelog_url) do
"github.com/mperham/sidekiq/blob/master/Pro-Changes.md"
end

before do
suggested_github_response =
fixture("github", "contents_sidekiq.json")
suggested_github_url =
"https://api.github.com/repos/mperham/sidekiq/contents/"
stub_request(:get, suggested_github_url)
.to_return(status: 200,
body: suggested_github_response,
headers: { "Content-Type" => "application/json" })
"https:/github.com/mperham/sidekiq/blob/master/Pro-Changes.md#v2.8.6"
end

it "gets the right URL" do
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion updater/Gemfile.lock
Expand Up @@ -339,7 +339,7 @@ GEM
rubocop-rspec_rails (~> 2.28)
rubocop-rspec_rails (2.28.3)
rubocop (~> 1.40)
rubocop-sorbet (0.8.1)
rubocop-sorbet (0.8.2)
rubocop (>= 0.90.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
Expand Down

0 comments on commit 409e8ed

Please sign in to comment.