Skip to content

Commit

Permalink
Fix linter offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
gopidesupavan authored and randhircs committed Jan 16, 2025
1 parent 8aad5ca commit c6ba49d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 87 deletions.
6 changes: 3 additions & 3 deletions github_actions/lib/dependabot/github_actions/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def self.new(version)

sig { params(version: VersionParameter).returns(VersionParameter) }
def self.remove_leading_v(version)
return version unless version.to_s.match?(/\A(?:.*\/)?v?([0-9])/)
return version unless version.to_s.match?(%r{\A(?:.*/)?v?([0-9])})

version.to_s.sub(/\A(?:.*\/)?v?/, "")
version.to_s.sub(%r{\A(?:.*/)?v?}, "")
end

sig { params(version: VersionParameter).returns(T::Boolean) }
def self.path_based?(version)
version.to_s.match?(/\A.+\/v?([0-9])/)
version.to_s.match?(%r{\A.+/v?([0-9])})
end

sig { override.params(version: VersionParameter).returns(T::Boolean) }
Expand Down
148 changes: 64 additions & 84 deletions github_actions/spec/dependabot/github_actions/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1107,80 +1107,41 @@
"https://github.com/gopidesupavan/monorepo-actions.git/info/refs" \
"?service=git-upload-pack"
end
before do
stub_request(:get, service_pack_url)
.to_return(
status: 200,
body: fixture("git", "upload_packs", "github-monorepo-path-based"),
headers: {
"content-type" => "application/x-git-upload-pack-advertisement"
}
)
end
let(:upload_pack_fixture) { "github-monorepo-path-based" }
let(:dependency) do
Dependabot::Dependency.new(
name: "gopidesupavan/monorepo-actions/first/run@run/v1.0.0",
version: "1.0.0",
requirements: [{
requirement: nil,
groups: [],
file: ".github/workflows/workflow.yml",
source: {
type: "git",
url: "https://github.com/gopidesupavan/monorepo-actions",
ref: "run/v1.0.0",
branch: nil
},
metadata: { declaration_string: "gopidesupavan/monorepo-actions/first/run@run/v1.0.0" }
}],
requirement: nil,
groups: [],
file: ".github/workflows/workflow.yml",
source: {
type: "git",
url: "https://github.com/gopidesupavan/monorepo-actions",
ref: "run/v1.0.0",
branch: nil
},
metadata: { declaration_string: "gopidesupavan/monorepo-actions/first/run@run/v1.0.0" }
}],
package_manager: "github_actions"
)
end

let(:expected_requirements) do
[{
requirement: nil,
groups: [],
file: ".github/workflows/workflow.yml",
source: {
type: "git",
url: "https://github.com/gopidesupavan/monorepo-actions",
ref: "run/v3.0.0",
branch: nil
},
metadata: { declaration_string: "gopidesupavan/monorepo-actions/first/run@run/v1.0.0" }
}]
requirement: nil,
groups: [],
file: ".github/workflows/workflow.yml",
source: {
type: "git",
url: "https://github.com/gopidesupavan/monorepo-actions",
ref: "run/v3.0.0",
branch: nil
},
metadata: { declaration_string: "gopidesupavan/monorepo-actions/first/run@run/v1.0.0" }
}]
end

it { is_expected.to eq(expected_requirements) }

# context "when the latest version is being ignored" do
# let(:ignored_versions) { [">= 1.1.0"] }
# let(:expected_requirements) do
# [{
# requirement: nil,
# groups: [],
# file: ".github/workflows/workflow.yml",
# source: {
# type: "git",
# url: "https://github.com/actions/setup-node",
# ref: "v1.0.4",
# branch: nil
# },
# metadata: { declaration_string: "actions/setup-node@master" }
# }]
# end
#
# it { is_expected.to eq(expected_requirements) }
# end
end

context "when a dependency has a path based tag reference without semver" do
let(:service_pack_url) do
"https://github.com/gopidesupavan/monorepo-actions.git/info/refs" \
"?service=git-upload-pack"
end
before do
stub_request(:get, service_pack_url)
.to_return(
Expand All @@ -1191,40 +1152,59 @@
}
)
end

it { is_expected.to eq(expected_requirements) }
end

context "when a dependency has a path based tag reference without semver" do
let(:service_pack_url) do
"https://github.com/gopidesupavan/monorepo-actions.git/info/refs" \
"?service=git-upload-pack"
end
let(:upload_pack_fixture) { "github-monorepo-path-based" }
let(:dependency) do
Dependabot::Dependency.new(
name: "gopidesupavan/monorepo-actions/second/exec@exec/1.0.0",
version: "1.0.0",
requirements: [{
requirement: nil,
groups: [],
file: ".github/workflows/workflow.yml",
source: {
type: "git",
url: "https://github.com/gopidesupavan/monorepo-actions",
ref: "exec/1.0.0",
branch: nil
},
metadata: { declaration_string: "gopidesupavan/monorepo-actions/second/exec@exec/1.0.0" }
}],
requirement: nil,
groups: [],
file: ".github/workflows/workflow.yml",
source: {
type: "git",
url: "https://github.com/gopidesupavan/monorepo-actions",
ref: "exec/1.0.0",
branch: nil
},
metadata: { declaration_string: "gopidesupavan/monorepo-actions/second/exec@exec/1.0.0" }
}],
package_manager: "github_actions"
)
end

let(:expected_requirements) do
[{
requirement: nil,
groups: [],
file: ".github/workflows/workflow.yml",
source: {
type: "git",
url: "https://github.com/gopidesupavan/monorepo-actions",
ref: "exec/2.0.0",
branch: nil
},
metadata: { declaration_string: "gopidesupavan/monorepo-actions/second/exec@exec/1.0.0" }
}]
requirement: nil,
groups: [],
file: ".github/workflows/workflow.yml",
source: {
type: "git",
url: "https://github.com/gopidesupavan/monorepo-actions",
ref: "exec/2.0.0",
branch: nil
},
metadata: { declaration_string: "gopidesupavan/monorepo-actions/second/exec@exec/1.0.0" }
}]
end

before do
stub_request(:get, service_pack_url)
.to_return(
status: 200,
body: fixture("git", "upload_packs", "github-monorepo-path-based"),
headers: {
"content-type" => "application/x-git-upload-pack-advertisement"
}
)
end

it { is_expected.to eq(expected_requirements) }
Expand Down

0 comments on commit c6ba49d

Please sign in to comment.