au 0.2.3 → 0.3.0

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: 3c887e57c864ce6b7ba438d75b02abcff5fac7ec169fe620cbd9b0cbcde97fb0
4
- data.tar.gz: 5274a3ae886c455de17b72ec24d7ff4a158ea77e2364ad13963dc02a4a10ef7f
3
+ metadata.gz: e7ea421673dfacd4c6379ebf129019ad69c89e5d464c64e3b71e4856fea168e8
4
+ data.tar.gz: 02aaf3aec6ce229206bde2d97541718a996ab33a38274c7a7027c3077aef86d1
5
5
  SHA512:
6
- metadata.gz: 3bd410ab8f4d26920750423c2d4808fd26eac8cc75ccf7f79adebe14d3537b780a75f0068d06cf19e550a39b2af733f4ea175c4361e7decfaea83734ba88e602
7
- data.tar.gz: b7612b9814730869872fa9b20c249ee16eb41d76fd3c79e2660d1478ecd8ab47012a3d67f9fa3b2d52865c5c7e0d88e198f37fbf2b08e7e3ac32eba5bfd2f897
6
+ metadata.gz: cc34e78c8ebf418f4f6ee07ca3318d33b23f13743671d090b88fba621c73279f3b417ef236a64c38710462b0aab201463a392a054bcca506c6359c6b9fc7b57b
7
+ data.tar.gz: 9cf08469aafac200c35c01679e84cb5700023bfe49a20983f87acd8a9e8df6662e80d0a02dfe5425b674bd785644d13d42610ebecc92a00f598edbac42329de1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- au (0.2.3)
4
+ au (0.3.0)
5
5
  colorize
6
6
  thor
7
7
 
data/bin/au CHANGED
@@ -118,11 +118,15 @@ module Au
118
118
  desc "commit", "Commit staged files"
119
119
  option :m
120
120
  def commit
121
- created_commit_id = Repository.instance.commit(options[:m])
122
- if created_commit_id
123
- puts "Created commit #{created_commit_id}"
124
- else
125
- puts 'Please stage your changes first.'
121
+ begin
122
+ created_commit_id = Repository.instance.commit(options[:m])
123
+ if created_commit_id
124
+ puts "Created commit #{created_commit_id}"
125
+ else
126
+ puts 'Please stage your changes first.'
127
+ end
128
+ rescue => e
129
+ puts e.message
126
130
  end
127
131
  end
128
132
 
@@ -21,7 +21,7 @@ module Au
21
21
 
22
22
  def self.list
23
23
  db.transaction(true) do
24
- puts db.roots
24
+ db.roots
25
25
  end
26
26
  end
27
27
 
@@ -49,6 +49,21 @@ module Au
49
49
  parent_commit = find(parent_commit_id)
50
50
  new_doc_diff_ids = {}
51
51
 
52
+ # Check if this commit exists somewhere in the repository already
53
+ if Commit.list.any?
54
+ Commit.list.each do |commit|
55
+ same = true
56
+ other_commit = find(commit)
57
+ if other_commit.doc_diff_ids.length == staged_file_paths.length
58
+ Document.find(staged_file_paths).each do |doc|
59
+ # pass in the diff id for this doc from parent commit, if present
60
+ same = ((doc.diff(other_commit ? other_commit.doc_diff_ids[doc.path] : nil) == '') ? same : false)
61
+ end
62
+ raise ('Error: Duplicate commit with ' + commit) if same
63
+ end
64
+ end
65
+ end
66
+
52
67
  Document.find(staged_file_paths).each do |doc|
53
68
  # pass in the diff id for this doc from parent commit, if present
54
69
  diff_id = doc.create_diff(parent_commit ? parent_commit.doc_diff_ids[doc.path] : nil)
@@ -38,6 +38,10 @@ module Au
38
38
  file_in_other_state = content_from(other_diff_id)
39
39
  diff3_args = "#{abs_path} #{file_in_ancestor_state.path} #{file_in_other_state.path}"
40
40
 
41
+ # diff3 has issue when this file and other file are identical, but ancestor is different,
42
+ # so we need a special case for identical files
43
+ return if (`diff -c #{abs_path} #{file_in_other_state.path}` == '')
44
+
41
45
  has_conflict = !`diff3 -x #{diff3_args}`.empty?
42
46
  merged_content = `diff3 --merge #{diff3_args}`
43
47
  File.open(abs_path, 'w'){ |f| f.write(merged_content) }
@@ -1,3 +1,3 @@
1
1
  module Au
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: au
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edward Du
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-12-07 00:00:00.000000000 Z
13
+ date: 2018-12-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor