dependabot-common 0.140.0 → 0.140.1
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 +4 -4
- data/lib/dependabot/dependency_file.rb +24 -5
- data/lib/dependabot/file_updaters/vendor_updater.rb +12 -4
- data/lib/dependabot/pull_request_creator/github.rb +1 -1
- data/lib/dependabot/pull_request_creator/gitlab.rb +16 -13
- data/lib/dependabot/pull_request_updater/github.rb +1 -1
- data/lib/dependabot/pull_request_updater/gitlab.rb +12 -1
- data/lib/dependabot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3d8d2c38530262cc825130faa28497e3ce5eed2a6b6e2e53b573ebebf8852e6
|
4
|
+
data.tar.gz: 0ba1270c2b0f274ab20184bb504c9e109e2586ee8a6e1e959d1c5f9c3c665f61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 363e147e1bc8240fba5fb50afbe0b5fa3af4d8b195a621ecaac6de52eacf7df0c9cf0d589ea422a91d1428c9e5841882814e2c37ddeb98e553323123a99b0b2b
|
7
|
+
data.tar.gz: 0ac8544ba1909dab8c0cc47ec3c301b0066af52a2a0519a0697b4556a7715ed7510086f4b9ec787d88160abec8f2b49bc8051985c7e52fe0fb9e94f00de6f820
|
@@ -5,23 +5,33 @@ require "pathname"
|
|
5
5
|
module Dependabot
|
6
6
|
class DependencyFile
|
7
7
|
attr_accessor :name, :content, :directory, :type, :support_file,
|
8
|
-
:symlink_target, :content_encoding, :
|
8
|
+
:symlink_target, :content_encoding, :operation
|
9
9
|
|
10
10
|
class ContentEncoding
|
11
11
|
UTF_8 = "utf-8"
|
12
12
|
BASE64 = "base64"
|
13
13
|
end
|
14
14
|
|
15
|
+
class Operation
|
16
|
+
UPDATE = "update"
|
17
|
+
CREATE = "create"
|
18
|
+
DELETE = "delete"
|
19
|
+
end
|
20
|
+
|
15
21
|
def initialize(name:, content:, directory: "/", type: "file",
|
16
22
|
support_file: false, symlink_target: nil,
|
17
|
-
content_encoding: ContentEncoding::UTF_8, deleted: false)
|
23
|
+
content_encoding: ContentEncoding::UTF_8, deleted: false, operation: Operation::UPDATE)
|
18
24
|
@name = name
|
19
25
|
@content = content
|
20
26
|
@directory = clean_directory(directory)
|
21
27
|
@symlink_target = symlink_target
|
22
28
|
@support_file = support_file
|
23
29
|
@content_encoding = content_encoding
|
24
|
-
@
|
30
|
+
@operation = operation
|
31
|
+
|
32
|
+
# Make deleted override the operation. Deleted is kept when operation
|
33
|
+
# was introduced to keep compatibility with downstream dependants.
|
34
|
+
@operation = Operation::DELETE if deleted
|
25
35
|
|
26
36
|
# Type is used *very* sparingly. It lets the git_modules updater know that
|
27
37
|
# a "file" is actually a submodule, and lets our Go updaters know which
|
@@ -44,7 +54,8 @@ module Dependabot
|
|
44
54
|
"type" => type,
|
45
55
|
"support_file" => support_file,
|
46
56
|
"content_encoding" => content_encoding,
|
47
|
-
"deleted" => deleted
|
57
|
+
"deleted" => deleted,
|
58
|
+
"operation" => operation
|
48
59
|
}
|
49
60
|
|
50
61
|
details["symlink_target"] = symlink_target if symlink_target
|
@@ -75,8 +86,16 @@ module Dependabot
|
|
75
86
|
@support_file
|
76
87
|
end
|
77
88
|
|
89
|
+
def deleted
|
90
|
+
@operation == Operation::DELETE
|
91
|
+
end
|
92
|
+
|
93
|
+
def deleted=(deleted)
|
94
|
+
@operation = deleted ? Operation::DELETE : Operation::UPDATE
|
95
|
+
end
|
96
|
+
|
78
97
|
def deleted?
|
79
|
-
|
98
|
+
deleted
|
80
99
|
end
|
81
100
|
|
82
101
|
def binary?
|
@@ -27,12 +27,20 @@ module Dependabot
|
|
27
27
|
)
|
28
28
|
changed_paths = status.split("\n").map { |l| l.split(" ") }
|
29
29
|
changed_paths.map do |type, path|
|
30
|
-
|
30
|
+
# The following types are possible to be returned:
|
31
|
+
# M = Modified = Default for DependencyFile
|
32
|
+
# D = Deleted
|
33
|
+
# ?? = Untracked = Created
|
34
|
+
operation = Dependabot::DependencyFile::Operation::UPDATE
|
35
|
+
operation = Dependabot::DependencyFile::Operation::DELETE if type == "D"
|
36
|
+
operation = Dependabot::DependencyFile::Operation::CREATE if type == "??"
|
31
37
|
encoding = ""
|
32
|
-
encoded_content = File.read(path) unless
|
38
|
+
encoded_content = File.read(path) unless operation == Dependabot::DependencyFile::Operation::DELETE
|
33
39
|
if binary_file?(path)
|
34
40
|
encoding = Dependabot::DependencyFile::ContentEncoding::BASE64
|
35
|
-
|
41
|
+
if operation != Dependabot::DependencyFile::Operation::DELETE
|
42
|
+
encoded_content = Base64.encode64(encoded_content)
|
43
|
+
end
|
36
44
|
end
|
37
45
|
|
38
46
|
project_root =
|
@@ -44,7 +52,7 @@ module Dependabot
|
|
44
52
|
name: file_path.to_s,
|
45
53
|
content: encoded_content,
|
46
54
|
directory: base_directory,
|
47
|
-
|
55
|
+
operation: operation,
|
48
56
|
content_encoding: encoding
|
49
57
|
)
|
50
58
|
end
|
@@ -177,7 +177,7 @@ module Dependabot
|
|
177
177
|
sha: file.content
|
178
178
|
}
|
179
179
|
else
|
180
|
-
content = if file.
|
180
|
+
content = if file.operation == Dependabot::DependencyFile::Operation::DELETE
|
181
181
|
{ sha: nil }
|
182
182
|
elsif file.binary?
|
183
183
|
sha = github_client_for_source.create_blob(
|
@@ -91,23 +91,26 @@ module Dependabot
|
|
91
91
|
)
|
92
92
|
end
|
93
93
|
|
94
|
+
# @param [DependencyFile] file
|
95
|
+
def file_action(file)
|
96
|
+
if file.operation == Dependabot::DependencyFile::Operation::DELETE
|
97
|
+
"delete"
|
98
|
+
elsif file.operation == Dependabot::DependencyFile::Operation::CREATE
|
99
|
+
"create"
|
100
|
+
else
|
101
|
+
"update"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
94
105
|
def create_commit
|
95
106
|
return create_submodule_update_commit if files.count == 1 && files.first.type == "submodule"
|
96
107
|
|
97
108
|
actions = files.map do |file|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
}
|
104
|
-
else
|
105
|
-
{
|
106
|
-
action: "update",
|
107
|
-
file_path: file.path,
|
108
|
-
content: file.content
|
109
|
-
}
|
110
|
-
end
|
109
|
+
{
|
110
|
+
action: file_action(file),
|
111
|
+
file_path: file.type == "symlink" ? file.symlink_target : file.path,
|
112
|
+
content: file.content
|
113
|
+
}
|
111
114
|
end
|
112
115
|
|
113
116
|
gitlab_client_for_source.create_commit(
|
@@ -132,7 +132,7 @@ module Dependabot
|
|
132
132
|
sha: file.content
|
133
133
|
}
|
134
134
|
else
|
135
|
-
content = if file.
|
135
|
+
content = if file.operation == Dependabot::DependencyFile::Operation::DELETE
|
136
136
|
{ sha: nil }
|
137
137
|
elsif file.binary?
|
138
138
|
sha = github_client_for_source.create_blob(
|
@@ -62,10 +62,21 @@ module Dependabot
|
|
62
62
|
gitlab_client_for_source.commit(source.repo, old_commit)
|
63
63
|
end
|
64
64
|
|
65
|
+
# @param [DependencyFile] file
|
66
|
+
def file_action(file)
|
67
|
+
if file.operation == Dependabot::DependencyFile::Operation::DELETE
|
68
|
+
"delete"
|
69
|
+
elsif file.operation == Dependabot::DependencyFile::Operation::CREATE
|
70
|
+
"create"
|
71
|
+
else
|
72
|
+
"update"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
65
76
|
def create_commit
|
66
77
|
actions = files.map do |file|
|
67
78
|
{
|
68
|
-
action:
|
79
|
+
action: file_action(file),
|
69
80
|
file_path: file.type == "symlink" ? file.symlink_target : file.path,
|
70
81
|
content: file.content
|
71
82
|
}
|
data/lib/dependabot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dependabot-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.140.
|
4
|
+
version: 0.140.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dependabot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|