dtk-network-client 1.0.2.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f1ff40ca24da3d17fc294c77cbed86bb7e479e03
4
- data.tar.gz: a6cd9e86c645434e2a4951927a152e709151eb2c
2
+ SHA256:
3
+ metadata.gz: 60294cb4242addf43fe09d861d20279bbbc8d1fe504dfd8579c2f26ac802ee4a
4
+ data.tar.gz: 66d4697096d8741052f8a9987b60cb92f32165d804b9e6c5f507edc84d0fc48e
5
5
  SHA512:
6
- metadata.gz: 1fac71eae8b356c399112583fd573fcad603789a55437fc25156946fb8e05ab56e128ba2afeab5d8195de70d0d7c380057d7db0b63a30e7953958a9308deade1
7
- data.tar.gz: d79b3d329737bdae2db3d11c0e96355f8c443b7dfb6ba8d3bdc3ed7de910060840b47d3f9f8e6fb46829903331d66cf8f2b03b48fc8fba7ce2f0154f81c879bc
6
+ metadata.gz: 5e868d8514a0c56abf2067eae5d80d1ba29080eb749ed6f17266557b7cdbe12bca875d07f4cf61067713be83eb295a3b7fe745ef04355d64857afea2e48aa163
7
+ data.tar.gz: 03752513e6b7da71a876e2e896edff23054a8f9446c0765a4685bfdc8c480616de565f075db6aace4a723bbb0c31ba420c86fb9c88793101c8670f603b3ad00b
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.require_paths = ['lib']
15
15
  spec.files = `git ls-files`.split("\n")
16
16
 
17
- spec.add_dependency 'git', '1.4.0'
17
+ spec.add_dependency 'git', '~> 1.4.0'
18
18
  spec.add_dependency 'semverly', '~> 1.0'
19
19
  spec.add_dependency 'rest-client', '~> 1.7.3'
20
20
  # spec.add_dependency 'aws-sdk', '~> 3'
@@ -21,7 +21,8 @@ module DTK::Network::Client
21
21
  git_args = Args.new({
22
22
  repo_dir: @module_directory,
23
23
  branch: @module_ref.version.str_version,
24
- remote_url: remote_url
24
+ remote_url: remote_url,
25
+ force: @options[:force]
25
26
  })
26
27
  GitRepo.pull_from_remote(git_args)
27
28
  end
@@ -24,10 +24,11 @@ module DTK::Network::Client
24
24
  remote_url: remote_url,
25
25
  force: @options[:force]
26
26
  })
27
-
27
+
28
28
  begin
29
- GitRepo.push_to_remote(git_args)
29
+ diffs = GitRepo.push_to_remote(git_args)
30
30
  rescue Git::GitExecuteError => e
31
+ raise e.message if @options[:force]
31
32
  raise "Unable to do fast-forward push. You can use '--force' option to force push you changes to remote!"
32
33
  end
33
34
 
@@ -39,7 +40,7 @@ module DTK::Network::Client
39
40
  end
40
41
 
41
42
  rest_post("modules/#{module_info['id']}/dependencies", { version: @module_ref.version.str_version, dependencies: dependencies.to_json })
42
- nil
43
+ diffs
43
44
  end
44
45
 
45
46
  # TODO: move construct_remote_url to helper or mixin and use for all commands when needed
@@ -34,12 +34,14 @@ module DTK::Network::Client
34
34
  repo.checkout(local_branch, new_branch: create_if_missing)
35
35
  repo.add_all
36
36
  repo.commit(commit_msg, :allow_empty => true)
37
+ diffs = repo.diff_name_status("#{remote}/#{remote_branch}")
37
38
 
38
39
  if repo.is_there_remote?(remote)
39
40
  push_when_there_is_remote(repo, remote, remote_url, remote_branch, { force: force })
40
41
  else
41
42
  add_remote_and_push(repo, remote, remote_url, remote_branch, { force: force })
42
43
  end
44
+ diffs
43
45
  end
44
46
  end
45
47
 
@@ -50,14 +52,15 @@ module DTK::Network::Client
50
52
  local_branch = git_args[:branch] || 'master'
51
53
  remote_branch = git_args[:remote_branch] || local_branch
52
54
  remote = git_args[:remote] || 'origin'
55
+ force = git_args[:force]
53
56
 
54
57
  repo = git_repo.new(repo_dir, :branch => local_branch)
55
58
  repo.checkout(local_branch)
56
59
 
57
60
  if repo.is_there_remote?(remote)
58
- pull_when_there_is_remote(repo, remote, remote_url, remote_branch)
61
+ pull_when_there_is_remote(repo, remote, remote_url, local_branch, remote_branch, { force: force })
59
62
  else
60
- add_remote_and_pull(repo, remote, remote_url, remote_branch)
63
+ add_remote_and_pull(repo, remote, remote_url, local_branch, remote_branch, { force: force })
61
64
  end
62
65
  end
63
66
  end
@@ -89,9 +92,9 @@ module DTK::Network::Client
89
92
  add_remote_and_push(repo, remote, remote_url, remote_branch, opts)
90
93
  end
91
94
 
92
- def self.pull_when_there_is_remote(repo, remote, remote_url, remote_branch)
95
+ def self.pull_when_there_is_remote(repo, remote, remote_url, local_branch, remote_branch, opts = {})
93
96
  repo.remove_remote(remote)
94
- add_remote_and_pull(repo, remote, remote_url, remote_branch)
97
+ add_remote_and_pull(repo, remote, remote_url, local_branch, remote_branch, opts)
95
98
  end
96
99
 
97
100
  def self.add_remote_and_push(repo, remote, remote_url, remote_branch, opts = {})
@@ -99,9 +102,14 @@ module DTK::Network::Client
99
102
  repo.push(remote, remote_branch, opts)
100
103
  end
101
104
 
102
- def self.add_remote_and_pull(repo, remote, remote_url, remote_branch)
105
+ def self.add_remote_and_pull(repo, remote, remote_url, local_branch, remote_branch, opts = {})
103
106
  repo.add_remote(remote, remote_url)
104
- repo.pull(remote, remote_branch)
107
+ opts[:force] ? force_pull(repo, remote, remote_branch) : reset_if_error(repo, local_branch) { repo.pull(remote, remote_branch) }
108
+ end
109
+
110
+ def self.force_pull(repo, remote, remote_branch)
111
+ repo.fetch(remote)
112
+ repo.reset_hard("#{remote}/#{remote_branch}")
105
113
  end
106
114
 
107
115
  def self.local_branch_exist?(repo, branch)
@@ -217,6 +225,20 @@ module DTK::Network::Client
217
225
  repo.head_commit_sha
218
226
  end
219
227
 
228
+ def self.reset_if_error(repo, branch, &block)
229
+ ret = nil
230
+ begin
231
+ sha_before_operations = repo.revparse(branch)
232
+ ret = yield
233
+ rescue => e
234
+ # reset to enable checkout of another branch
235
+ repo.add_all
236
+ repo.reset_hard(sha_before_operations)
237
+ raise e
238
+ end
239
+ ret
240
+ end
241
+
220
242
  end
221
243
  end
222
244
 
@@ -1,7 +1,7 @@
1
1
  module DTK
2
2
  module Network
3
3
  module Client
4
- VERSION="1.0.2.1"
4
+ VERSION="1.0.3"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtk-network-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reactor8
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-08 00:00:00.000000000 Z
11
+ date: 2018-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.4.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
26
  version: 1.4.0
27
27
  - !ruby/object:Gem::Dependency
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  requirements: []
178
178
  rubyforge_project:
179
- rubygems_version: 2.6.11
179
+ rubygems_version: 2.7.8
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: Library for interaction with dtk network.