copernicium 0.2.2 → 0.2.3

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/lib/banners.rb +13 -3
  3. data/lib/repos.rb +27 -17
  4. data/lib/ui.rb +18 -17
  5. data/lib/workspace.rb +8 -5
  6. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbb6fba68a58e08a40c7ce16a1e17bc9eccfbffe
4
- data.tar.gz: a758b66457ad81b6a60678250154d71d3f85d448
3
+ metadata.gz: eb6640d45f2e8340d6773a90b84562c18f49e081
4
+ data.tar.gz: b7167785efeb0792ef678319288627cc6c1c1c18
5
5
  SHA512:
6
- metadata.gz: 9fb0f72fc70a568d58573e0e245955694c2e9bffc7e4356058fedd7274b9999268496dd35e428f0bd670070309e31c70094490561901bd370a8ab283d4641be2
7
- data.tar.gz: 9c31d2562c0e248161c60ee7e2f0ad6c84c29a04d80764dc0ef40ae9d4edb63e7c2f431da39c591369f79197b2785525c54a5a69b095abef18ae822f690dcf44
6
+ metadata.gz: 087e52e28beb477b9b588812f1874f2cd98ba982c12585e794ace85a5c7afd114b88b1ab279a365a9f5fb8627c4b86f4c308a3104742c63db1baea94a86d1833
7
+ data.tar.gz: b6dc121c1b32d9905f41254af357c9ff90387497d9f5fe921245cb8870b0acfc28724bfed6c962408ac38da65def9e29effca7f9f76e0ea506daccbc045585b9
data/lib/banners.rb CHANGED
@@ -54,14 +54,24 @@ EOS
54
54
 
55
55
 
56
56
  IN_REPO_WARNING = <<-EOS
57
- You are currently in a Copernicium repo... `cn init` is not valid here!
57
+ You are currently in a Copernicium repo...
58
+ `cn init` is not valid here!
58
59
  EOS
59
60
 
60
61
  NO_REPO_WARNING = <<-EOS
61
- You are not currently in a Copernicium repo... run `cn init` to create one!
62
+ You are not currently in a Copernicium repo...
63
+ Run `cn init` to create one!
62
64
  EOS
63
65
 
64
66
  AUTHOR_BANNER = <<-EOS
65
- todo
67
+ Jeremy Warner
68
+ Luisa Neves
69
+ Chris Wong
70
+ Xiang-Ru Lian
71
+ Logan Gittelson
72
+ Linfeng Song
73
+ Qiguang Liu
74
+ Frank Tamburrino
75
+ Ethan Johnson
66
76
  EOS
67
77
 
data/lib/repos.rb CHANGED
@@ -104,6 +104,16 @@ module Copernicium
104
104
  File.write @@hist, YAML.dump(@@history) # write history
105
105
  end
106
106
 
107
+ def Repos.merge_history(branch, hist)
108
+ @@history[branch] = sort_history(@@history[branch] + hist).uniq
109
+ end
110
+
111
+ def Repos.sort_history(hist)
112
+ #fails if there is no snapshot with the target id (a | b)
113
+ #hist.sort { |a, b| get_snapshot(a).date <=> get_snapshot(b).date }
114
+ hist
115
+ end
116
+
107
117
  # Return array of snapshot IDs
108
118
  def Repos.history(branch = nil)
109
119
  if branch.nil? # return a list of unique all commits
@@ -268,51 +278,51 @@ module Copernicium
268
278
  # bc each snapshot in our repo is atomic, not diffed
269
279
  # snap here is the id of a specific commit id
270
280
  # 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
281
 
277
282
  # FOR PUSHPULL UPDATE
278
- # - give a comm with username hist to merge
283
+ # - give a comm with user's history to merge
279
284
  def Repos.update(comm = UIComm.new)
280
285
  merge_name = File.join(@@copn, 'merging_' + comm.opts)
281
- status = "Remote is either up-to-date or ahead of local"
282
286
 
283
- if File.exist?(merge_name)
287
+ if File.exist?(merge_name) # merge history
284
288
  branches = YAML.load File.read(merge_name)
289
+ statuses = {}
285
290
 
286
291
  # merge @@history with remote hash
287
292
  branches.each do |branch, hist|
288
- if Repos.has_branch? branch
293
+ statuses[branch] = 'is up-to-date with remote'
294
+ if Repos.has_branch? branch # update
289
295
  hist.each_with_index do |snap, i|
290
296
 
297
+ #byebug
291
298
  # merger hist length is longer than ours
292
299
  if @@history[branch][i].nil?
293
- status = "Updated successfully"
300
+ statuses[branch] = 'updated successfully'
294
301
  Repos.merge_history branch, hist
295
302
  break
296
303
 
297
- # merger hist diverged from our system
304
+ # merger hist diverged from our system
298
305
  elsif @@history[branch][i] != snap
299
- status = "Merged remote history with local"
306
+ statuses[branch] = 'merged history with local'
300
307
  Repos.merge_history branch, hist
301
308
  break
302
- end
309
+
310
+ end # else synchronized - no differences
303
311
  end # will exit cleanly if we are more up-to-date
304
312
  else # branch does not exist locally yet, copy
313
+ statuses[branch] = 'created ok'
305
314
  @@history[branch] = hist
306
315
  end
307
- end
316
+ puts "Success: ".grn + "#{branch} ".yel + statuses[branch]
317
+ end # end branch iterations
308
318
 
309
- puts 'Result: '.grn + status
310
- File.delete(merge_name)
319
+ # cleaning up...persist
320
+ File.delete merge_name
311
321
  update_history
312
- return status
313
322
  else
314
323
  puts 'Error updating: '.red + merge_name + ' does not exist.'
315
324
  end
325
+ statuses
316
326
  end # update
317
327
  end # Repos
318
328
  end # Copernicium
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.2"
4
+ VERSION = "0.2.3"
5
5
 
6
6
  include Copernicium::PushPull
7
7
 
@@ -139,14 +139,15 @@ module Copernicium
139
139
  branch = args.shift
140
140
  if branch.nil? # show all branches
141
141
  puts "Current: ".grn + Repos.current
142
- puts "Branches: ".grn + Repos.branches.join(' ')
142
+ Repos.branches.each { |br| puts 'Branch: ' + br }
143
+ puts "Total: ".grn + Repos.branches.length.to_s
143
144
 
144
- elsif branch == '-c' # try to create a new branch
145
+ elsif branch == '-c' # create a new branch
145
146
  branch = args.first # get from the user
146
147
  branch = get "new branch name" if branch.nil?
147
148
  create_branch branch
148
149
 
149
- elsif branch == '-r' # rename the current branch
150
+ elsif branch == '-r' # rename branch
150
151
  newname = args.first # get if not specified
151
152
  newname = get "new name for current branch" if newname.nil?
152
153
  oldname = Repos.current
@@ -155,7 +156,7 @@ module Copernicium
155
156
  puts "Deleted branch '#{oldname}'".grn
156
157
  puts "Renamed branch '#{oldname}' to '#{newname}'".grn
157
158
 
158
- elsif branch == '-d' # Delete the specified branch
159
+ elsif branch == '-d' # delete branch
159
160
  branch = args.first # If not specified, get
160
161
  branch = get "branch to delete" if branch.nil?
161
162
  if branch == Repos.current
@@ -167,7 +168,7 @@ module Copernicium
167
168
 
168
169
  elsif Repos.has_branch? branch # switch branch (branch <branch name>)
169
170
  Repos.update_branch branch
170
- puts "Current: ".grn + Repos.current
171
+ puts 'Current: '.grn + Repos.current
171
172
  Workspace.checkout
172
173
 
173
174
  else # create it, switch to it
@@ -180,8 +181,8 @@ module Copernicium
180
181
  def clonecn(args)
181
182
  user = args.first
182
183
  host = args.last
183
- user = get "username for push" if user.nil?
184
- host = get "host path (<host:/dir/of/repo>)" if host.nil? || user == host
184
+ user = get 'username for push' if user.nil?
185
+ host = get 'host path (<host:/dir/of/repo>)' if host.nil? || user == host
185
186
  comm = UIComm.new(command: 'clone', repo: host, opts: user)
186
187
  PushPull.UICommandParser(comm)
187
188
  return comm
@@ -190,8 +191,8 @@ module Copernicium
190
191
  def push(args)
191
192
  user = args.first
192
193
  host = args.last
193
- user = get "username for push" if user.nil?
194
- host = get "host path (<host:/dir/of/repo>)" if host.nil? || user == host
194
+ user = get 'username for push' if user.nil?
195
+ host = get 'host path (<host:/dir/of/repo>)' if host.nil? || user == host
195
196
  comm = UIComm.new(command: 'push', repo: host, opts: user)
196
197
  PushPull.UICommandParser(comm)
197
198
  return comm
@@ -200,8 +201,8 @@ module Copernicium
200
201
  def pull(args)
201
202
  user = args.first
202
203
  host = args.last
203
- user = get "username for push" if user.nil?
204
- host = get "host path (<host:/dir/of/repo>)" if host.nil? || user == host
204
+ user = get 'username for push' if user.nil?
205
+ host = get 'host path (<host:/dir/of/repo>)' if host.nil? || user == host
205
206
  comm = UIComm.new(command: 'pull', repo: host, opts: user)
206
207
  PushPull.UICommandParser(comm)
207
208
  return comm
@@ -214,7 +215,7 @@ module Copernicium
214
215
  rev = get 'branch or commit id'
215
216
  else
216
217
  rev = args.shift
217
- files = args
218
+ files = args unless args.empty?
218
219
  end
219
220
 
220
221
  # if 'head' keyword, grab the head
@@ -252,7 +253,7 @@ module Copernicium
252
253
 
253
254
  # perform the commit, with workspace
254
255
  ui = UIComm.new(command: 'commit', files: files, cmt_msg: message)
255
- puts "New commit: ".grn + Workspace.commit(ui)
256
+ puts 'New commit: '.grn + Workspace.commit(ui)
256
257
  ui
257
258
  end
258
259
 
@@ -274,16 +275,16 @@ module Copernicium
274
275
  rev = (Repos.history rev).last
275
276
  conflicts = Workspace.merge(rev)
276
277
  unless conflicts.nil?
277
- conflicts.each { |conflict| puts "Conflict: ".red + conflict }
278
+ conflicts.each { |conflict| puts 'Conflict: '.red + conflict }
278
279
  end
279
280
  else # branch not found
280
- puts "Branch not found: ".red + rev
281
+ puts 'Branch not found: '.red + rev
281
282
  end
282
283
  end
283
284
 
284
285
  def update(args)
285
286
  if args.empty?
286
- username = get "user to update to"
287
+ username = get 'user to update to'
287
288
  else
288
289
  username = args.first
289
290
  end
data/lib/workspace.rb CHANGED
@@ -1,10 +1,11 @@
1
- # workspace module - linfeng and qiguang
2
-
1
+ # workspace module
2
+ # linfeng song, qiguang liu
3
3
 
4
4
  module Copernicium
5
5
  class FileObj
6
- attr_reader :path, :history
6
+ attr_reader :path, :base, :history
7
7
  def initialize(path, ids)
8
+ @base = File.dirname(path)
8
9
  @history = ids
9
10
  @path = path
10
11
  end
@@ -123,6 +124,7 @@ module Copernicium
123
124
  def Workspace.checkout_file(file)
124
125
  idx = indexOf(file.path)
125
126
  idx.nil?? @@files << file : @@files[idx] = file
127
+ Dir.mkdir file.base unless Dir.exist? file.base
126
128
  File.write(file.path, RevLog.get_file(file.last))
127
129
  end
128
130
 
@@ -136,8 +138,9 @@ module Copernicium
136
138
  Workspace.checkout_file file
137
139
  end
138
140
  else # just checkout given files
139
- Repos.get_snapshot(comm.rev).files.select { |f|
140
- comm.files.include? f.path }.each do |file|
141
+ Repos.get_snapshot(comm.rev).files.select do |f|
142
+ comm.files.include? f.path
143
+ end .each do |file|
141
144
  Workspace.checkout_file file
142
145
  end
143
146
  end
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.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Copernicium