txgh 7.0.0.beta4 → 7.0.0.beta5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/txgh/git_api.rb +0 -67
- data/lib/txgh/gitlab_api.rb +3 -2
- data/lib/txgh/version.rb +1 -1
- data/spec/github_api_spec.rb +1 -1
- data/spec/gitlab_api_spec.rb +5 -5
- 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: 83666fa045f577661ee033da2f8d07151aabf8a70f05a7009e4886163d8a7b80
|
4
|
+
data.tar.gz: 3d309e4dd07b942cee64ac861f0e821e057b7ac8f4f25bab6593c1819ba550c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbdc40b7dde617ed3431e6b87d3cd36b18a5300d150dab984ade909ca412418f720d53fa08de11e49655e279a1db546ccc58a96e092ad78491824dad56226b7d
|
7
|
+
data.tar.gz: f81028991588b2f481a42db9760ba3a34009cb697802ef9daee8c7bbeed62e8eb9623d07de3bd7d94c65bf3a25ca52ab8232acb87d24538bdba73d2a4f0a1137
|
data/lib/txgh/git_api.rb
CHANGED
@@ -14,72 +14,5 @@ module Txgh
|
|
14
14
|
@client = client
|
15
15
|
@repo_name = repo_name
|
16
16
|
end
|
17
|
-
|
18
|
-
def tree(sha)
|
19
|
-
client.tree(repo_name, sha, recursive: 1)
|
20
|
-
end
|
21
|
-
|
22
|
-
def blob(sha)
|
23
|
-
client.blob(repo_name, sha)
|
24
|
-
end
|
25
|
-
|
26
|
-
def create_ref(branch, sha)
|
27
|
-
client.create_ref(repo_name, branch, sha) rescue false
|
28
|
-
end
|
29
|
-
|
30
|
-
def update_contents(branch, content_list, message)
|
31
|
-
content_list.each do |file_params|
|
32
|
-
path = file_params.fetch(:path)
|
33
|
-
new_contents = file_params.fetch(:contents)
|
34
|
-
branch = Utils.relative_branch(branch)
|
35
|
-
|
36
|
-
file_sha = file_params.fetch(:sha) do
|
37
|
-
begin
|
38
|
-
client.contents(repo_name, { path: path, ref: branch })[:sha]
|
39
|
-
rescue Octokit::NotFound
|
40
|
-
nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# If the file doesnt exist, then it isn't tracked by git and file_sha
|
45
|
-
# will be nil. In git land, a SHA of all zeroes means create a new file
|
46
|
-
# instead of updating an existing one.
|
47
|
-
current_sha = file_sha || '0' * 40
|
48
|
-
new_sha = Utils.git_hash_blob(new_contents)
|
49
|
-
options = { branch: branch }
|
50
|
-
|
51
|
-
if current_sha != new_sha
|
52
|
-
client.update_contents(
|
53
|
-
repo_name, path, message, current_sha, new_contents, options
|
54
|
-
)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def get_commit(sha)
|
60
|
-
client.commit(repo_name, sha)
|
61
|
-
end
|
62
|
-
|
63
|
-
def get_ref(ref)
|
64
|
-
client.ref(repo_name, ref)
|
65
|
-
end
|
66
|
-
|
67
|
-
def download(path, branch)
|
68
|
-
file = client.contents(repo_name, { path: path, ref: branch }).to_h
|
69
|
-
|
70
|
-
file[:content] = case file[:encoding]
|
71
|
-
when 'base64'
|
72
|
-
Base64.decode64(file[:content])
|
73
|
-
else
|
74
|
-
file[:content].force_encoding(file[:encoding])
|
75
|
-
end
|
76
|
-
|
77
|
-
file.delete(:encoding)
|
78
|
-
file
|
79
|
-
end
|
80
|
-
|
81
|
-
def create_status(sha, state, options = {})
|
82
|
-
client.create_status(repo_name, sha, state, options)
|
83
|
-
end
|
84
17
|
end
|
85
18
|
end
|
data/lib/txgh/gitlab_api.rb
CHANGED
@@ -20,7 +20,7 @@ module Txgh
|
|
20
20
|
|
21
21
|
file_sha = file_params.fetch(:sha) do
|
22
22
|
begin
|
23
|
-
client.get_file(repo_name, path, branch).
|
23
|
+
client.get_file(repo_name, path, branch).blob_id
|
24
24
|
rescue ::Gitlab::Error::NotFound
|
25
25
|
nil
|
26
26
|
end
|
@@ -52,7 +52,8 @@ module Txgh
|
|
52
52
|
|
53
53
|
# mock github response
|
54
54
|
{
|
55
|
-
content: file.encoding == 'base64' ? Base64.decode64(file.content) : file.content.force_encoding(file.encoding)
|
55
|
+
content: file.encoding == 'base64' ? Base64.decode64(file.content) : file.content.force_encoding(file.encoding),
|
56
|
+
path: path
|
56
57
|
}
|
57
58
|
end
|
58
59
|
|
data/lib/txgh/version.rb
CHANGED
data/spec/github_api_spec.rb
CHANGED
@@ -37,7 +37,7 @@ describe Txgh::GithubApi do
|
|
37
37
|
describe '#update_contents' do
|
38
38
|
let(:path) { 'path/to/file.txt' }
|
39
39
|
let(:old_contents) { 'abc123' }
|
40
|
-
let(:old_sha) { Utils.git_hash_blob(old_contents) }
|
40
|
+
let(:old_sha) { Txgh::Utils.git_hash_blob(old_contents) }
|
41
41
|
|
42
42
|
it 'updates the given file contents' do
|
43
43
|
new_contents = 'def456'
|
data/spec/gitlab_api_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe Txgh::GitlabApi do
|
|
21
21
|
describe '#update_contents' do
|
22
22
|
let(:path) { 'path/to/file.txt' }
|
23
23
|
let(:old_contents) { 'abc123' }
|
24
|
-
let(:old_sha) { Utils.git_hash_blob(old_contents) }
|
24
|
+
let(:old_sha) { Txgh::Utils.git_hash_blob(old_contents) }
|
25
25
|
|
26
26
|
it 'updates the given file contents' do
|
27
27
|
new_contents = 'def456'
|
@@ -29,7 +29,7 @@ describe Txgh::GitlabApi do
|
|
29
29
|
expect(client).to(
|
30
30
|
receive(:get_file)
|
31
31
|
.with(repo, path, branch)
|
32
|
-
.and_return(double(
|
32
|
+
.and_return(double(blob_id: old_sha))
|
33
33
|
)
|
34
34
|
|
35
35
|
expect(client).to(
|
@@ -44,7 +44,7 @@ describe Txgh::GitlabApi do
|
|
44
44
|
expect(client).to(
|
45
45
|
receive(:get_file)
|
46
46
|
.with(repo, path, branch)
|
47
|
-
.and_return(double(
|
47
|
+
.and_return(double(blob_id: old_sha))
|
48
48
|
)
|
49
49
|
|
50
50
|
expect(client).to_not receive(:edit_file)
|
@@ -82,7 +82,7 @@ describe Txgh::GitlabApi do
|
|
82
82
|
.and_return(double(content: 'content', encoding: 'utf-8'))
|
83
83
|
)
|
84
84
|
|
85
|
-
expect(api.download(path, branch)).to eq({ content: 'content' })
|
85
|
+
expect(api.download(path, branch)).to eq({ content: 'content', path: path })
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'encodes the string using the encoding specified in the response' do
|
@@ -106,7 +106,7 @@ describe Txgh::GitlabApi do
|
|
106
106
|
.and_return(double(content: Base64.encode64('content'), encoding: 'base64'))
|
107
107
|
)
|
108
108
|
|
109
|
-
expect(api.download(path, branch)).to eq({ content: 'content' })
|
109
|
+
expect(api.download(path, branch)).to eq({ content: 'content', path: path })
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: txgh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.0.
|
4
|
+
version: 7.0.0.beta5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Jackowski
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-03-
|
12
|
+
date: 2020-03-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: abroad
|