txgh 7.0.0.beta4 → 7.0.0.beta5

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: 115f8465e3521a85f6ebb9fb137410cdef753203d30dca1343bc00261d832db9
4
- data.tar.gz: d3b5774e8a1d1699e7dd47b5537d74075004b3b2def59f8457c259ad518d8c7a
3
+ metadata.gz: 83666fa045f577661ee033da2f8d07151aabf8a70f05a7009e4886163d8a7b80
4
+ data.tar.gz: 3d309e4dd07b942cee64ac861f0e821e057b7ac8f4f25bab6593c1819ba550c6
5
5
  SHA512:
6
- metadata.gz: 566fe97c0391c74fc21924b101f34727956bd3cc1a49c31f47b8a8c30d2a86876c9f3997ce8e8daa89584e2971bed0211843c3120e5f783293996cedaae3add9
7
- data.tar.gz: 9986dfc7e5875e0c1b0ae8534d71ba02d86f2c2b2ad995930ebb52fe92bfe723a2e0a99ea9a61b7b813dca627e94ce4002e85940b2e97065bbf917bc477b9f16
6
+ metadata.gz: dbdc40b7dde617ed3431e6b87d3cd36b18a5300d150dab984ade909ca412418f720d53fa08de11e49655e279a1db546ccc58a96e092ad78491824dad56226b7d
7
+ data.tar.gz: f81028991588b2f481a42db9760ba3a34009cb697802ef9daee8c7bbeed62e8eb9623d07de3bd7d94c65bf3a25ca52ab8232acb87d24538bdba73d2a4f0a1137
@@ -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
@@ -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).content_sha256
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
 
@@ -1,3 +1,3 @@
1
1
  module Txgh
2
- VERSION = '7.0.0.beta4'
2
+ VERSION = '7.0.0.beta5'
3
3
  end
@@ -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'
@@ -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(content_sha256: old_sha))
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(content_sha256: old_sha))
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.beta4
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-26 00:00:00.000000000 Z
12
+ date: 2020-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: abroad