Skip to content

Commit

Permalink
Merge pull request dependabot#3541 from kd7lxl/git-describe
Browse files Browse the repository at this point in the history
docker: handle versions generated with `git describe --tags --long`
  • Loading branch information
thepwagner authored Apr 29, 2021
2 parents 85410c0 + 4965a9b commit 3fce13b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
7 changes: 3 additions & 4 deletions docker/lib/dependabot/docker/update_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ def comparable_tags_from_registry(version)
tags_from_registry.
select { |tag| tag.match?(NAME_WITH_VERSION) }.
select { |tag| prefix_of(tag) == original_prefix }.
select { |tag| suffix_of(tag) == original_suffix }.
select { |tag| format_of(tag) == original_format }.
reject { |tag| commit_sha_suffix?(tag) }
select { |tag| suffix_of(tag) == original_suffix || commit_sha_suffix?(tag) }.
select { |tag| format_of(tag) == original_format }
end

def remove_version_downgrades(candidate_tags, version)
Expand All @@ -190,7 +189,7 @@ def commit_sha_suffix?(tag)
# can't order on those but will try to, so instead we should exclude
# them (unless there's a `latest` version pushed to the registry, in
# which case we'll use that to find the latest version)
return false unless tag.match?(/(^|\-)[0-9a-f]{7,}$/)
return false unless tag.match?(/(^|\-g?)[0-9a-f]{7,}$/)

!tag.match?(/(^|\-)\d+$/)
end
Expand Down
6 changes: 6 additions & 0 deletions docker/spec/dependabot/docker/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@
end
end

context "when the dependency version is generated with git describe --tags --long" do
let(:tags_fixture_name) { "git_describe.json" }
let(:version) { "v3.9.0-177-ged5bcde" }
it { is_expected.to eq("v3.10.0-169-gfe040d3") }
end

context "when the docker registry times out" do
before do
stub_request(:get, repo_url + "tags/list").
Expand Down
41 changes: 41 additions & 0 deletions docker/spec/fixtures/docker/registry_tags/git_describe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "infoblox/grafana-operator",
"tags": [
"v3.2.0-10-g0208ead",
"v3.2.0-10-g17a8c8f",
"v3.2.0-10-g2fe2e69",
"v3.2.0-10-g3a24f62",
"v3.2.0-10-gd2eda66",
"v3.2.0-11-gb85335c",
"v3.2.0-11-gffe830d",
"v3.2.0-12-gbb83bba",
"v3.2.0-12-gd0ca143",
"v3.2.0-12-gfe00835",
"v3.2.0-13-gb4ee0f2",
"v3.2.0-164-ge71f8af",
"v3.2.0-230-gbabf17f",
"v3.2.0-6-g2d0df1d",
"v3.2.0-6-g42944f4",
"v3.2.0-6-gdcf49b7",
"v3.2.0-7-g52cd8b3",
"v3.2.0-7-g634e39d",
"v3.2.0-7-gf7faf90",
"v3.2.0-7-gfad2538",
"v3.2.0-7-gff3ea81",
"v3.2.0-8-g1648a84",
"v3.2.0-8-g1ca2017",
"v3.2.0-8-gf4eeefd",
"v3.2.0-9-g12202a3",
"v3.7.0-13-g02d4c9ef",
"v3.7.0-14-g051e1a97",
"v3.7.0-15-g5c997230",
"v3.7.0-16-ga9d63825",
"v3.7.0-16-gd5a70ddc",
"v3.7.0-18-ga7fdf65c",
"v3.9.0-173-g4d84d01",
"v3.9.0-177-ged5bcde",
"v3.9.0-181-gbabf17f",
"v3.10.0-17-gfefefef",
"v3.10.0-169-gfe040d3"
]
}
4 changes: 4 additions & 0 deletions docker/spec/fixtures/docker/registry_tags/sha_suffices.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"7.1-2f653d4",
"7.1-5621d67",
"7.1-7b82110",
"7.1-g7b82110",
"7.1-b5b6a49",
"7.1-9658143",
"7.1-98060af",
Expand All @@ -23,6 +24,7 @@
"7.1-d2d733e",
"7.1-b7a6caf",
"7.1-790dd8b",
"7.1-g790dd8b",
"7.2",
"7.2-0.3.1",
"7.2-0.3",
Expand All @@ -33,6 +35,8 @@
"7.2-0.1.2",
"7.2-0.1.1",
"7.2-0.1",
"7.2-g7b82110",
"7.2-g790dd8b",
"7.2-7b82110",
"7.2-790dd8b",
"7.2-ce5a8af",
Expand Down

0 comments on commit 3fce13b

Please sign in to comment.