copernicium 0.2.1 → 0.2.2

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
2
  SHA1:
3
- metadata.gz: 10780d8221be1720570ca3e1b2c6cd60ea7235e0
4
- data.tar.gz: de4d95fefe2dce4d81d323946db88db272380a48
3
+ metadata.gz: fbb6fba68a58e08a40c7ce16a1e17bc9eccfbffe
4
+ data.tar.gz: a758b66457ad81b6a60678250154d71d3f85d448
5
5
  SHA512:
6
- metadata.gz: 493c6dc906e01453e355de01a6e137a92e563c990218390f18d0d4a9fbc08ce6cc9a603bda2a47e80fd0a60eaea309062988a4282bdfde33f11d6632fd469a6a
7
- data.tar.gz: b8981fde53cbc665a9137ee1eacc71cb211e09770c7c8efff51194242997941692169a0cc628ced1e1ac29e849839f6089e70553653601f1c6f363c9aa1177c2
6
+ metadata.gz: 9fb0f72fc70a568d58573e0e245955694c2e9bffc7e4356058fedd7274b9999268496dd35e428f0bd670070309e31c70094490561901bd370a8ab283d4641be2
7
+ data.tar.gz: 9c31d2562c0e248161c60ee7e2f0ad6c84c29a04d80764dc0ef40ae9d4edb63e7c2f431da39c591369f79197b2785525c54a5a69b095abef18ae822f690dcf44
data/lib/pushpull.rb CHANGED
@@ -22,7 +22,7 @@ module Copernicium
22
22
  @@host = remote[0]
23
23
  @@path = remote[1]
24
24
  elsif remote.length == 1
25
- @@host = "cycle3.csug.rochester.edu"
25
+ @@host = "cycle1.csug.rochester.edu"
26
26
  @@path = remote.first
27
27
  else
28
28
  raise 'Remote host information not given.'.red
@@ -129,6 +129,7 @@ module Copernicium
129
129
  #
130
130
  # Description:
131
131
  # pushes local changes on the current branch to a remote branch
132
+ #
132
133
  def PushPull.ppush
133
134
  begin
134
135
  PushPull.transfer do |ssh|
@@ -146,6 +147,7 @@ module Copernicium
146
147
 
147
148
  PushPull.connect do |ssh|
148
149
  puts ssh.exec! "cd #{@@path} && cn update #{@@user}"
150
+ puts ssh.exec! "cd #{@@path} && cn checkout head"
149
151
  end
150
152
  rescue => error
151
153
  connection_failure "trying to push files", error
@@ -163,17 +165,18 @@ module Copernicium
163
165
  begin
164
166
  PushPull.fetch do |session|
165
167
  # uploading our history to remote
166
- session.download!("#{@@path}/.cn/merging_#{@@user}",
167
- "#{Dir.pwd}/.cn/history")
168
+ session.download!( "#{@@path}/.cn/history",
169
+ "#{Dir.pwd}/.cn/merging_#{@@user}")
168
170
 
169
171
  # uploading our .cn info to remote
170
172
  %w{revs snap}.each do |file|
171
173
  session.download!("#{@@path}/.cn/#{file}",
172
174
  "#{Dir.pwd}/.cn/",
173
- :recursive => true)
175
+ :recursive => true)
174
176
  end
175
177
  end
176
178
  system "cn update", @@user
179
+ system "cn checkout head"
177
180
  puts "Remote pulled: ".grn + @@host + @@path
178
181
  rescue => error
179
182
  connection_failure "trying to pull files", error
data/lib/repos.rb CHANGED
@@ -263,38 +263,55 @@ module Copernicium
263
263
  update_history
264
264
  end
265
265
 
266
+ # only append commits that arent already in there
267
+ # thus - the order is not the same, but that is ok
268
+ # bc each snapshot in our repo is atomic, not diffed
269
+ # snap here is the id of a specific commit id
270
+ # todo - optionally sort these by timestamp, sync
271
+ def Repos.merge_history(branch, hist)
272
+ hist.each do |snap|
273
+ @@history[branch] << snap unless @@history[branch].include? snap
274
+ end
275
+ end
276
+
266
277
  # FOR PUSHPULL UPDATE
278
+ # - give a comm with username hist to merge
267
279
  def Repos.update(comm = UIComm.new)
268
- merge_name = File.join(@@copn, 'merging_'+comm.opts)
280
+ merge_name = File.join(@@copn, 'merging_' + comm.opts)
269
281
  status = "Remote is either up-to-date or ahead of local"
270
282
 
271
283
  if File.exist?(merge_name)
272
- merger = YAML.load File.read(merge_name)
273
-
274
- # merge @@history with merger hash
275
- merger.each do |key, val|
276
- if @@history.keys.include? key
277
- val.each_with_index do |snap, index|
278
- if @@history[key][index].nil?
279
- @@history[key] += val[index..-1]
280
- status = "Updated remote successfully"
281
- elsif @@history[key][index] == snap
282
- next
283
- elsif @@history[key][index] != snap
284
- @@history[key] += val[index..-1]
284
+ branches = YAML.load File.read(merge_name)
285
+
286
+ # merge @@history with remote hash
287
+ branches.each do |branch, hist|
288
+ if Repos.has_branch? branch
289
+ hist.each_with_index do |snap, i|
290
+
291
+ # merger hist length is longer than ours
292
+ if @@history[branch][i].nil?
293
+ status = "Updated successfully"
294
+ Repos.merge_history branch, hist
295
+ break
296
+
297
+ # merger hist diverged from our system
298
+ elsif @@history[branch][i] != snap
285
299
  status = "Merged remote history with local"
300
+ Repos.merge_history branch, hist
301
+ break
286
302
  end
287
- end
288
- else
289
- @@history[key] = val
303
+ end # will exit cleanly if we are more up-to-date
304
+ else # branch does not exist locally yet, copy
305
+ @@history[branch] = hist
290
306
  end
291
307
  end
292
308
 
309
+ puts 'Result: '.grn + status
293
310
  File.delete(merge_name)
294
311
  update_history
295
- puts status
312
+ return status
296
313
  else
297
- puts 'Error updating: '.red + merge_name + 'doesnt exist.'
314
+ puts 'Error updating: '.red + merge_name + ' does not exist.'
298
315
  end
299
316
  end # update
300
317
  end # Repos
data/lib/ui.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # user interface module - parse and execute commands
2
2
  # integrates all modules, central module
3
3
 
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
 
6
6
  include Copernicium::PushPull
7
7
 
data/lib/workspace.rb CHANGED
@@ -173,7 +173,7 @@ module Copernicium
173
173
  elsif remov.include? x
174
174
  @@files.delete_at(indexOf x)
175
175
  else
176
- puts 'Failed, no changes: '.yel + x
176
+ puts 'No changes: '.yel + x
177
177
  end
178
178
  end
179
179
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copernicium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Copernicium