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 +4 -4
- data/Gemfile.lock +1 -1
- data/bin/au +9 -5
- data/lib/au/models/commit.rb +16 -1
- data/lib/au/models/document.rb +4 -0
- data/lib/au/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7ea421673dfacd4c6379ebf129019ad69c89e5d464c64e3b71e4856fea168e8
|
4
|
+
data.tar.gz: 02aaf3aec6ce229206bde2d97541718a996ab33a38274c7a7027c3077aef86d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc34e78c8ebf418f4f6ee07ca3318d33b23f13743671d090b88fba621c73279f3b417ef236a64c38710462b0aab201463a392a054bcca506c6359c6b9fc7b57b
|
7
|
+
data.tar.gz: 9cf08469aafac200c35c01679e84cb5700023bfe49a20983f87acd8a9e8df6662e80d0a02dfe5425b674bd785644d13d42610ebecc92a00f598edbac42329de1
|
data/Gemfile.lock
CHANGED
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
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
|
data/lib/au/models/commit.rb
CHANGED
@@ -21,7 +21,7 @@ module Au
|
|
21
21
|
|
22
22
|
def self.list
|
23
23
|
db.transaction(true) do
|
24
|
-
|
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)
|
data/lib/au/models/document.rb
CHANGED
@@ -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) }
|
data/lib/au/version.rb
CHANGED
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.
|
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-
|
13
|
+
date: 2018-12-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|