dtk-client 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWFhMGY3ZWUzYzgxMjM3MjJlZmI2MDJmMTdlOTkzZjFkYmQ2ODJiMQ==
4
+ OGM2YzcyZjU0NTk3ZmY1MTUyYzJlZjQ3YmFkYzhjOGE5N2M4OTUxZQ==
5
5
  data.tar.gz: !binary |-
6
- YWVjMmRiMGE4NWFjN2U4M2QyYTJkN2Q5YTgxNWU5NmJkN2Q2MmIxNQ==
6
+ YWJlMTcxYzE0OGQwYWJlZjZjM2E4NTIxNGY5YTZmZjY1ZTk2ZjM0NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MmNhNTcwYzllZmY5MTRhMTdlZDRhOTg0ZGQxNTNkMzU0YWMzMTdlZDUyZjg3
10
- NzIwYWIwMzk0MmMzNGE1ZmExMWY1YmJiZTk5YmZlM2QzMjQ0MGE0OTRhZDE2
11
- Yzg3ZGJiYWVhNTcyYjA2OWIwMTZlMTU3YTFmMjQwY2VmNGE3YTA=
9
+ ZWY1YmJlODNlOGEzYTU5ZGFiYzlhOTdmZDNlYTM0Y2QzNjllOTQyZDZkNjM0
10
+ NGQ5ZDUxZDg2YjA0MmQ2NTUwNDNkNDkwNzFjZDc3NGYyZDgxMGRhZmQyY2Rh
11
+ MTc4Yzc2OTJjZjRkYmM3ZjEyYzRlMjBiNGQzMGM3OTM3Njk5MGQ=
12
12
  data.tar.gz: !binary |-
13
- OTczZjRiOWI4NDBkZDNiZGMzMWFhNjAyNWU3NDZmZjVmZDQ1NjM4ZTEyODIy
14
- MDIyZjUxMTkwZDE3Yzg0NDBkYTUwYjAyNzljZDcxMzIwNWE2ZThiMzk3Y2I1
15
- YWRlNTg5YWJiOTM0MzBkOTg1OTYxMWE5ZDE2NDUzY2NkNjZjYTc=
13
+ YjkxNDdhOGEwNzI0MWZhNGI4OWEzNjQ4YjM3ZWEzYzA2MWM3NGExM2Y1MGMw
14
+ ZWE2ZDI1NWFjYjUzODI5MDBkMDZjMTA3Y2I2ZmYyMTNiOThhOTExZWMzY2Iz
15
+ OTEwMWJkZDc0NDljYjY1ZDM1ZWU1MDk1ZjIwMjBkM2VmYjc0YTQ=
@@ -109,7 +109,7 @@ module DTK; module Client; class CommandHelper
109
109
  Response::Ok.new()
110
110
  end
111
111
 
112
- #if local clone exists remove its .git directory
112
+ # if local clone exists remove its .git directory
113
113
  def unlink_local_clone?(type,module_name,version=nil)
114
114
  Response.wrap_helper_actions() do
115
115
  local_repo_dir = local_repo_dir(type,module_name,version)
@@ -148,7 +148,7 @@ module DTK; module Client; class CommandHelper
148
148
  end
149
149
  end
150
150
 
151
- #makes repo_dir (determined from type and module_name) into a git dir, pulls, adds, content and then pushes
151
+ # makes repo_dir (determined from type and module_name) into a git dir, pulls, adds, content and then pushes
152
152
  def initialize_client_clone_and_push(type,module_name,branch,repo_url,local_repo_dir,version=nil)
153
153
  # moved this part from 'check_local_dir_exists_with_content' to this method since this only deletes .git folder
154
154
  # which can cause us problems if import fails
@@ -180,7 +180,7 @@ module DTK; module Client; class CommandHelper
180
180
  end
181
181
 
182
182
  private
183
- #TODO: in common expose Common::GritAdapter at less nested level
183
+ # TODO: in common expose Common::GritAdapter at less nested level
184
184
  class DiffSummary < ::DTK::Common::SimpleHashObject
185
185
  def self.new_version(repo)
186
186
  new(repo.new_version())
@@ -321,7 +321,7 @@ module DTK; module Client; class CommandHelper
321
321
  end
322
322
 
323
323
  # default commit in case it is needed
324
- repo.commit("Commit prior to pull from remote") if repo.changed?
324
+ repo.stage_and_commit("Commit prior to pull from remote") if repo.changed?
325
325
 
326
326
  #check if merge needed
327
327
  merge_rel = repo.merge_relationship(:remote_branch,remote_branch_ref)
@@ -11,13 +11,14 @@ module DTK
11
11
  end
12
12
 
13
13
  def changed?
14
- (!(@git_repo.status.changed.empty? && @git_repo.status.untracked.empty? && @git_repo.status.deleted.empty?) || staged_commits?)
14
+ (!(changed().empty? && untracked().empty? && deleted().empty?) || staged_commits?)
15
15
  end
16
16
 
17
17
  def stage_changes()
18
- @git_repo.add(@git_repo.status.untracked().keys)
19
- @git_repo.add(@git_repo.status.changed().keys)
20
- @git_repo.status.deleted().each do |file, status|
18
+ @git_repo.add(untracked())
19
+ @git_repo.add(added())
20
+ @git_repo.add(changed())
21
+ deleted().each do |file, status|
21
22
  # this indicates that change has not been staged
22
23
  if status.stage
23
24
  @git_repo.remove(file)
@@ -26,7 +27,7 @@ module DTK
26
27
  end
27
28
 
28
29
  def print_status()
29
- changes = [@git_repo.status.changed().keys, @git_repo.status.untracked().keys, @git_repo.status.deleted().keys]
30
+ changes = [changed(), untracked(), deleted()]
30
31
  puts "\nModified files:\n".colorize(:green) unless changes[0].empty?
31
32
  changes[0].each { |item| puts "\t#{item}" }
32
33
  puts "\nAdded files:\n".colorize(:yellow) unless changes[1].empty?
@@ -55,9 +56,9 @@ module DTK
55
56
 
56
57
  def local_summary()
57
58
  {
58
- :files_added => (@git_repo.status.untracked().keys + @git_repo.status.added().keys).collect { |file| { :path => file }},
59
- :files_modified => @git_repo.status.changed().keys.collect { |file| { :path => file }},
60
- :files_deleted => @git_repo.status.deleted().keys.collect { |file| { :path => file }}
59
+ :files_added => (untracked() + added()).collect { |file| { :path => file }},
60
+ :files_modified => changed().collect { |file| { :path => file }},
61
+ :files_deleted => deleted().collect { |file| { :path => file }}
61
62
  }
62
63
  end
63
64
 
@@ -65,6 +66,11 @@ module DTK
65
66
  return local_summary()
66
67
  end
67
68
 
69
+ def stage_and_commit(commit_msg = "")
70
+ stage_changes()
71
+ commit(commit_msg)
72
+ end
73
+
68
74
  def commit(commit_msg = "")
69
75
  @git_repo.commit(commit_msg)
70
76
  end
@@ -190,8 +196,51 @@ module DTK
190
196
  @git_repo.branches.local.find { |b| b.current }
191
197
  end
192
198
 
199
+ TEMP_BRANCH = "temp_branch"
200
+
201
+ def merge_theirs(remote_branch_ref)
202
+ branch = current_branch_name
203
+
204
+ # Git is not agile enoguh to work with following commands so we are using native commands to achive this
205
+ Dir.chdir(repo_dir) do
206
+ OsUtil.suspend_output do
207
+ puts `git checkout -b #{TEMP_BRANCH} #{remote_branch_ref}`
208
+ puts `git merge #{branch} -s ours`
209
+ puts `git checkout #{branch}`
210
+ puts `git reset #{TEMP_BRANCH} --hard`
211
+ puts `git branch -D #{TEMP_BRANCH}`
212
+ end
213
+ end
214
+ end
215
+
193
216
  private
194
217
 
218
+ # Method bellow show different behavior when working with 1.8.7
219
+ # so based on Hash response we know it it is:
220
+ # Hash => 1.9.3 +
221
+ # Array => 1.8.7
222
+ #
223
+
224
+ def changed
225
+ status.is_a?(Hash) ? status.changed().keys : status.changed().collect { |file| file.first }
226
+ end
227
+
228
+ def untracked
229
+ status.is_a?(Hash) ? status.untracked().keys : status.untracked().collect { |file| file.first }
230
+ end
231
+
232
+ def deleted
233
+ status.is_a?(Hash) ? status.deleted().keys : status.deleted().collect { |file| file.first }
234
+ end
235
+
236
+ def added
237
+ status.is_a?(Hash) ? status.added().keys : status.added().collect { |file| file.first }
238
+ end
239
+
240
+ def status
241
+ @git_repo.status
242
+ end
243
+
195
244
  def is_there_remote?(remote_name)
196
245
  @git_repo.remotes.find { |r| r.name == remote_name }
197
246
  end
@@ -1,3 +1,3 @@
1
1
  module DtkClient
2
- VERSION="0.5.8"
2
+ VERSION="0.5.9"
3
3
  end
data/lib/shell/context.rb CHANGED
@@ -185,7 +185,7 @@ module DTK
185
185
  extended_context = extended_context[:context]
186
186
  extended_context.reject!{|k,v| k.to_s!=line_buffer}
187
187
 
188
- new_context = extended_context[line_buffer.to_sym] unless line_buffer.nil?
188
+ new_context = extended_context[line_buffer.to_sym] unless line_buffer.nil? || line_buffer.empty?
189
189
  active_context_copy.push_new_context(new_context, new_context) unless new_context.nil?
190
190
  end
191
191
  end
@@ -693,7 +693,7 @@ module DTK
693
693
  valid_all_children = (root_clazz != command_clazz) ? (root_clazz.all_children() + root_clazz.valid_children()) : []
694
694
  n_level_ac_candidates = command_clazz.respond_to?(:valid_children) ? command_clazz.valid_children.map { |e| e.to_s } : []
695
695
 
696
- n_level_ac_candidates.keep_if{|v| valid_all_children.include?(v.to_sym)} unless valid_all_children.empty?
696
+ n_level_ac_candidates.select {|v| valid_all_children.include?(v.to_sym)} unless valid_all_children.empty?
697
697
  invisible_context = command_clazz.respond_to?(:invisible_context) ? command_clazz.invisible_context.map { |e| e.to_s } : []
698
698
 
699
699
  unless invisible_context.empty?
data/lib/util/os_util.rb CHANGED
@@ -221,6 +221,8 @@ module DTK
221
221
  load File.expand_path('../../lib/util/os_util.rb', File.dirname(__FILE__))
222
222
  load File.expand_path('../../lib/shell/help_monkey_patch.rb', File.dirname(__FILE__))
223
223
  load File.expand_path('../../lib/shell/domain.rb', File.dirname(__FILE__))
224
+ load File.expand_path('../../lib/domain/git_adapter.rb', File.dirname(__FILE__))
225
+ load File.expand_path('../../lib/command_helpers/git_repo.rb', File.dirname(__FILE__))
224
226
  path = File.expand_path('../../lib/commands/thor/*.rb', File.dirname(__FILE__))
225
227
  Dir[path].each do |thor_class_file|
226
228
  load thor_class_file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtk-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rich PELAVIN
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-05 00:00:00.000000000 Z
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler