dependabot-github_actions 0.211.0 → 0.213.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a755f2e216dc49388866fbceae4209313b2272d243691b331793313ab8842b8
4
- data.tar.gz: 15b4dec7f68b942709c3c260ffaeea6dd3fad49bf90e88b4189fca41da4bdc9e
3
+ metadata.gz: e40718bacbd579d5f066f1951840b92e43e2a4f9d18d35870b02e6cf43352a3d
4
+ data.tar.gz: df27ec63cc58ce499478d5d89f35f57b5d171a4cbc3487025e560efe6c4c8219
5
5
  SHA512:
6
- metadata.gz: 775c9fdb7b9090cd939ac0f23610403abe2cfd6da3bf8f602f2e5069d83ce532d68546af2571d31725b50c8736bfa966aeb363f160c4e1fddd224337fe021b53
7
- data.tar.gz: c972c2410a628a3a1a83c114652096a1112bd1e0aa830cbed9302a79322e4728b6a2a5d351bce5f224cea9e88dfa3719d5e9953d44f44d3f9e45f2978fb65355
6
+ metadata.gz: 855575e94d06e5749ee006e0a20180c8de9bbdb519b9adb894ac4cd943aaa2c852c1714a92a44ed4e6c7736c64cb9c74af5824825fdc2dd57e0977aee3dcfd6f
7
+ data.tar.gz: 8bca4abb38782199a213843eb76a8ffddb204db1d3e68ed1310a794d0893d1f8545e62cf64cfbea87fd62174ffa8af3d3661ff3c646f2540864a2cb49bfa396e
@@ -6,7 +6,7 @@ require "dependabot/file_fetchers/base"
6
6
  module Dependabot
7
7
  module GithubActions
8
8
  class FileFetcher < Dependabot::FileFetchers::Base
9
- FILENAME_PATTERN = /^(\.github|action.ya?ml)$/.freeze
9
+ FILENAME_PATTERN = /^(\.github|action.ya?ml)$/
10
10
 
11
11
  def self.required_files_in?(filenames)
12
12
  filenames.any? { |f| f.match?(FILENAME_PATTERN) }
@@ -21,7 +21,7 @@ module Dependabot
21
21
  (?<repo>[\w.-]+)
22
22
  (?<path>/[^\@]+)?
23
23
  @(?<ref>.+)
24
- }x.freeze
24
+ }x
25
25
 
26
26
  def parse
27
27
  dependency_set = DependencySet.new
@@ -109,7 +109,7 @@ module Dependabot
109
109
  steps = json_object.fetch("steps", [])
110
110
 
111
111
  uses_strings =
112
- if steps.is_a?(Array) && steps.all? { |s| s.is_a?(Hash) }
112
+ if steps.is_a?(Array) && steps.all?(Hash)
113
113
  steps.
114
114
  map { |step| step.fetch("uses", nil) }.
115
115
  select { |use| use.is_a?(String) }
@@ -65,17 +65,41 @@ module Dependabot
65
65
  gsub(/@.*+/, "@#{new_req.fetch(:source).fetch(:ref)}")
66
66
 
67
67
  # Replace the old declaration that's preceded by a non-word character
68
- # and followed by a whitespace character (comments) or EOL
68
+ # and followed by a whitespace character (comments) or EOL.
69
+ # If the declaration is followed by a comment that lists the version associated
70
+ # with the SHA source ref, then update the comment to the human-readable new version.
71
+ # However, if the comment includes additional text beyond the version, for safety
72
+ # we skip updating the comment in case it's a custom note, todo, warning etc of some kind.
73
+ # See the related unit tests for examples.
69
74
  updated_content =
70
75
  updated_content.
71
76
  gsub(
72
- /(?<=\W|"|')#{Regexp.escape(old_declaration)}(?=\s|"|'|$)/,
73
- new_declaration
74
- )
77
+ /(?<=\W|"|')#{Regexp.escape(old_declaration)}(?<comment>\s+#.*)?(?=\s|"|'|$)/
78
+ ) do |match|
79
+ comment = Regexp.last_match(:comment)
80
+ match.gsub!(old_declaration, new_declaration)
81
+ if comment && (updated_comment = updated_version_comment(comment, new_req))
82
+ match.gsub!(comment, updated_comment)
83
+ end
84
+ match
85
+ end
75
86
  end
76
87
 
77
88
  updated_content
78
89
  end
90
+
91
+ def updated_version_comment(comment, new_req)
92
+ raise "No comment!" unless comment
93
+
94
+ comment = comment.rstrip
95
+ return unless dependency.previous_version && dependency.version
96
+ return unless comment.end_with? dependency.previous_version
97
+
98
+ git_checker = Dependabot::GitCommitChecker.new(dependency: dependency, credentials: credentials)
99
+ return unless git_checker.ref_looks_like_commit_sha?(new_req.fetch(:source).fetch(:ref))
100
+
101
+ comment.gsub(dependency.previous_version, dependency.version)
102
+ end
79
103
  end
80
104
  end
81
105
  end
@@ -9,7 +9,7 @@ module Dependabot
9
9
  private
10
10
 
11
11
  def look_up_source
12
- info = dependency.requirements.map { |r| r[:source] }.compact.first
12
+ info = dependency.requirements.filter_map { |r| r[:source] }.first
13
13
 
14
14
  url =
15
15
  if info.nil?
@@ -7,7 +7,7 @@ module Dependabot
7
7
  module GithubActions
8
8
  # Lifted from the bundler package manager
9
9
  class Requirement < Gem::Requirement
10
- # For consistency with other langauges, we define a requirements array.
10
+ # For consistency with other languages, we define a requirements array.
11
11
  # Ruby doesn't have an `OR` separator for requirements, so it always
12
12
  # contains a single element.
13
13
  def self.requirements_array(requirement_string)
@@ -59,7 +59,7 @@ module Dependabot
59
59
  end
60
60
 
61
61
  def fetch_latest_version_for_git_dependency
62
- return git_commit_checker.head_commit_for_current_branch unless git_commit_checker.pinned?
62
+ return current_commit unless git_commit_checker.pinned?
63
63
 
64
64
  # If the dependency is pinned to a tag that looks like a version then
65
65
  # we want to update that tag.
@@ -70,11 +70,11 @@ module Dependabot
70
70
  return latest_version
71
71
  end
72
72
 
73
- # If the dependency is pinned to a commit SHA, we return a *version* so
74
- # that we get nice behaviour in PullRequestCreator::MessageBuilder
75
- if git_commit_checker.pinned_ref_looks_like_commit_sha?
76
- latest_tag = git_commit_checker.local_tag_for_latest_version
77
- return latest_tag.fetch(:version)
73
+ if git_commit_checker.pinned_ref_looks_like_commit_sha? && latest_version_tag
74
+ latest_version = latest_version_tag.fetch(:version)
75
+ return latest_commit_for_pinned_ref unless git_commit_checker.branch_or_ref_in_release?(latest_version)
76
+
77
+ return latest_version
78
78
  end
79
79
 
80
80
  # If the dependency is pinned to a tag that doesn't look like a
@@ -82,6 +82,15 @@ module Dependabot
82
82
  nil
83
83
  end
84
84
 
85
+ def latest_commit_for_pinned_ref
86
+ @latest_commit_for_pinned_ref ||=
87
+ SharedHelpers.in_a_temporary_repo_directory("/", repo_contents_path) do
88
+ ref_branch = find_container_branch(current_commit)
89
+
90
+ git_commit_checker.head_commit_for_local_branch(ref_branch)
91
+ end
92
+ end
93
+
85
94
  def latest_version_tag
86
95
  @latest_version_tag ||= begin
87
96
  return git_commit_checker.local_tag_for_latest_version if dependency.version.nil?
@@ -89,25 +98,15 @@ module Dependabot
89
98
  latest_tags = git_commit_checker.local_tags_for_latest_version_commit_sha
90
99
 
91
100
  # Find the latest version with the same precision as the pinned version.
92
- # Falls back to a version with the closest precision if no exact match.
93
- current_dots = dependency.version.split(".").length
94
- latest_tags.max do |a, b|
95
- next a[:version] <=> b[:version] unless shortened_semver_version_eq?(a[:version], b[:version])
96
-
97
- a_dots = a[:version].to_s.split(".").length
98
- b_dots = b[:version].to_s.split(".").length
99
- a_diff = (a_dots - current_dots).abs
100
- b_diff = (b_dots - current_dots).abs
101
- next -(a_diff <=> b_diff) unless a_diff == b_diff
102
-
103
- # preference to a less specific version if we have a tie
104
- next 1 if a_dots < current_dots
105
-
106
- -1
107
- end
101
+ current_precision = precision(dependency.version)
102
+ latest_tags.select { |tag| precision(tag[:version].to_s) == current_precision }.max_by { |tag| tag[:version] }
108
103
  end
109
104
  end
110
105
 
106
+ def precision(version)
107
+ version.split(".").length
108
+ end
109
+
111
110
  def updated_source
112
111
  # TODO: Support Docker sources
113
112
  return dependency_source_details unless git_dependency?
@@ -119,18 +118,28 @@ module Dependabot
119
118
  return dependency_source_details.merge(ref: new_tag.fetch(:tag))
120
119
  end
121
120
 
122
- latest_tag = git_commit_checker.local_tag_for_latest_version
123
-
124
121
  # Update the pinned git commit if one is available
125
122
  if git_commit_checker.pinned_ref_looks_like_commit_sha? &&
126
- latest_tag.fetch(:commit_sha) != current_commit
127
- return dependency_source_details.merge(ref: latest_tag.fetch(:commit_sha))
123
+ (new_commit_sha = latest_commit_sha) &&
124
+ new_commit_sha != current_commit
125
+ return dependency_source_details.merge(ref: new_commit_sha)
128
126
  end
129
127
 
130
128
  # Otherwise return the original source
131
129
  dependency_source_details
132
130
  end
133
131
 
132
+ def latest_commit_sha
133
+ new_tag = latest_version_tag
134
+ return unless new_tag
135
+
136
+ if git_commit_checker.branch_or_ref_in_release?(new_tag.fetch(:version))
137
+ new_tag.fetch(:commit_sha)
138
+ else
139
+ latest_commit_for_pinned_ref
140
+ end
141
+ end
142
+
134
143
  def dependency_source_details
135
144
  sources =
136
145
  dependency.requirements.map { |r| r.fetch(:source) }.uniq.compact
@@ -174,11 +183,21 @@ module Dependabot
174
183
  other_split[0..base_split.length - 1] == base_split
175
184
  end
176
185
 
177
- def shortened_semver_version_eq?(base_version, other_version)
178
- base = base_version.to_s
179
- other = other_version.to_s
186
+ def find_container_branch(sha)
187
+ SharedHelpers.run_shell_command("git fetch #{current_commit}")
188
+
189
+ branches_including_ref = SharedHelpers.run_shell_command("git branch --contains #{sha}").split("\n")
180
190
 
181
- shortened_semver_eq?(base, other) || shortened_semver_eq?(other, base)
191
+ current_branch = branches_including_ref.find { |line| line.start_with?("* ") }
192
+
193
+ if current_branch
194
+ current_branch.delete_prefix("* ")
195
+ elsif branches_including_ref.size > 1
196
+ # If there are multiple non default branches including the pinned SHA, then it's unclear how we should proceed
197
+ raise "Multiple ambiguous branches (#{branches_including_ref.join(', ')}) include #{current_commit}!"
198
+ else
199
+ branches_including_ref.first
200
+ end
182
201
  end
183
202
  end
184
203
  end
@@ -13,7 +13,7 @@ module Dependabot
13
13
  def self.remove_leading_v(version)
14
14
  return version unless version.to_s.match?(/\Av([0-9])/)
15
15
 
16
- version.to_s.gsub(/\Av/, "")
16
+ version.to_s.delete_prefix("v")
17
17
  end
18
18
 
19
19
  def self.correct?(version)
@@ -22,3 +22,6 @@ Dependabot::PullRequestCreator::Labeler.
22
22
  require "dependabot/dependency"
23
23
  Dependabot::Dependency.
24
24
  register_production_check("github_actions", ->(_) { true })
25
+
26
+ require "dependabot/utils"
27
+ Dependabot::Utils.register_always_clone("github_actions")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-github_actions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.211.0
4
+ version: 0.213.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-23 00:00:00.000000000 Z
11
+ date: 2022-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,42 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.211.0
19
+ version: 0.213.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.211.0
27
- - !ruby/object:Gem::Dependency
28
- name: debase
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '='
32
- - !ruby/object:Gem::Version
33
- version: 0.2.3
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '='
39
- - !ruby/object:Gem::Version
40
- version: 0.2.3
41
- - !ruby/object:Gem::Dependency
42
- name: debase-ruby_core_source
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '='
46
- - !ruby/object:Gem::Version
47
- version: 0.10.16
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: 0.10.16
26
+ version: 0.213.0
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: debug
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +58,14 @@ dependencies:
86
58
  requirements:
87
59
  - - "~>"
88
60
  - !ruby/object:Gem::Version
89
- version: 3.11.1
61
+ version: 3.13.0
90
62
  type: :development
91
63
  prerelease: false
92
64
  version_requirements: !ruby/object:Gem::Requirement
93
65
  requirements:
94
66
  - - "~>"
95
67
  - !ruby/object:Gem::Version
96
- version: 3.11.1
68
+ version: 3.13.0
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: rake
99
71
  requirement: !ruby/object:Gem::Requirement
@@ -142,28 +114,28 @@ dependencies:
142
114
  requirements:
143
115
  - - "~>"
144
116
  - !ruby/object:Gem::Version
145
- version: 1.35.1
117
+ version: 1.37.1
146
118
  type: :development
147
119
  prerelease: false
148
120
  version_requirements: !ruby/object:Gem::Requirement
149
121
  requirements:
150
122
  - - "~>"
151
123
  - !ruby/object:Gem::Version
152
- version: 1.35.1
124
+ version: 1.37.1
153
125
  - !ruby/object:Gem::Dependency
154
- name: ruby-debug-ide
126
+ name: rubocop-performance
155
127
  requirement: !ruby/object:Gem::Requirement
156
128
  requirements:
157
129
  - - "~>"
158
130
  - !ruby/object:Gem::Version
159
- version: 0.7.3
131
+ version: 1.15.0
160
132
  type: :development
161
133
  prerelease: false
162
134
  version_requirements: !ruby/object:Gem::Requirement
163
135
  requirements:
164
136
  - - "~>"
165
137
  - !ruby/object:Gem::Version
166
- version: 0.7.3
138
+ version: 1.15.0
167
139
  - !ruby/object:Gem::Dependency
168
140
  name: simplecov
169
141
  requirement: !ruby/object:Gem::Requirement
@@ -261,14 +233,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
261
233
  requirements:
262
234
  - - ">="
263
235
  - !ruby/object:Gem::Version
264
- version: 2.7.0
236
+ version: 3.1.0
265
237
  required_rubygems_version: !ruby/object:Gem::Requirement
266
238
  requirements:
267
239
  - - ">="
268
240
  - !ruby/object:Gem::Version
269
- version: 2.7.0
241
+ version: 3.1.0
270
242
  requirements: []
271
- rubygems_version: 3.1.6
243
+ rubygems_version: 3.3.7
272
244
  signing_key:
273
245
  specification_version: 4
274
246
  summary: GitHub Actions support for dependabot-common