ggsm 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -21
- data/lib/ggsm/flow/delete.rb +2 -6
- data/lib/ggsm/flow/finish.rb +2 -6
- data/lib/ggsm/flow/foreach.rb +2 -6
- data/lib/ggsm/flow/merge.rb +3 -6
- data/lib/ggsm/flow/start.rb +2 -6
- data/lib/ggsm/flow/switch.rb +23 -23
- data/lib/ggsm/util/submodule.rb +21 -3
- data/lib/ggsm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6047a2466f671d94d9ed1632af90fc1362c24a98
|
4
|
+
data.tar.gz: e171938265ea8db94e4b051e7ece45d1a9dec9e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2d39d480055c9ffcbc9ff9dc604ec7b6e635fc709b4c696a0a06e79fa1334729edff7a5d2f8bfe1fef1e1a47a9c2fa54e65391921c709aacded640453e0de91
|
7
|
+
data.tar.gz: be44fcddb27f8b8691f563124fc3dc3187db7993cabaa90479916ac53ec516f0b579e715fb4f997394ae813edf94a1e51ceb94cb9a91c7902ea3a7b6beb28949
|
data/README.md
CHANGED
@@ -1,35 +1,28 @@
|
|
1
1
|
# GGSM
|
2
|
-
|
2
|
+
Gitsubmodule workflow
|
3
3
|
|
4
4
|
## Installation
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
```ruby
|
9
|
-
gem 'ggsm'
|
10
|
-
```
|
11
|
-
|
12
|
-
And then execute:
|
13
|
-
|
14
|
-
$ bundle
|
15
|
-
|
16
|
-
Or install it yourself as:
|
6
|
+
Install it yourself as:
|
17
7
|
|
18
8
|
$ gem install ggsm
|
19
9
|
|
20
10
|
## Usage
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
11
|
+
````
|
12
|
+
Commands:
|
13
|
+
ggsm [help] [COMMAND] # 帮助
|
14
|
+
ggsm sync # 同步(拉取)远程代码
|
15
|
+
ggsm start <branch> [<commit>] [<origin>] # 检出新分支,新功能、修bug务必使用该命令
|
16
|
+
ggsm switch <branch> # 切换分支
|
17
|
+
ggsm merge [<branch>] # Merge,开发完成后执行
|
18
|
+
ggsm finish # Merge后并解决冲突后执行
|
19
|
+
ggsm delete <branch> [-r|--remote] [-a|--all] # 删除指定分支
|
20
|
+
ggsm foreach [<commands>...] # 所有模块执行git命令(foreach后跟git命令)
|
21
|
+
````
|
29
22
|
|
30
23
|
## Contributing
|
31
24
|
|
32
|
-
Bug reports and pull requests are welcome on GitHub https://github.com/YoKeyword/ggsm. This project is intended to be a safe, welcoming space for collaboration
|
25
|
+
Bug reports and pull requests are welcome on GitHub https://github.com/YoKeyword/ggsm. This project is intended to be a safe, welcoming space for collaboration.
|
33
26
|
|
34
27
|
|
35
28
|
## License
|
data/lib/ggsm/flow/delete.rb
CHANGED
@@ -13,13 +13,9 @@ module GGSM
|
|
13
13
|
|
14
14
|
delete_branch(all, branch, remote)
|
15
15
|
|
16
|
-
|
17
|
-
subs.each do |sub|
|
18
|
-
Dir.chdir sub
|
19
|
-
puts "==> 进入#{sub}:".yellow
|
16
|
+
foreach_module {
|
20
17
|
delete_branch(all, branch, remote)
|
21
|
-
|
22
|
-
end
|
18
|
+
}
|
23
19
|
end
|
24
20
|
|
25
21
|
def delete_branch(all, branch, remote)
|
data/lib/ggsm/flow/finish.rb
CHANGED
@@ -8,13 +8,9 @@ module GGSM
|
|
8
8
|
def finish_flow
|
9
9
|
check_submodule
|
10
10
|
|
11
|
-
|
12
|
-
subs.each do |sub|
|
13
|
-
Dir.chdir sub
|
14
|
-
puts "==> 进入#{sub}:".yellow
|
11
|
+
foreach_module {
|
15
12
|
system "git add .;git commit;git push origin #{get_current_branch}"
|
16
|
-
|
17
|
-
end
|
13
|
+
}
|
18
14
|
|
19
15
|
puts '==> 进入主工程:'.yellow
|
20
16
|
system "git add .;git commit;git push origin #{get_current_branch}"
|
data/lib/ggsm/flow/foreach.rb
CHANGED
@@ -22,13 +22,9 @@ module GGSM
|
|
22
22
|
cmd = "#{cmd} #{arg}"
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
subs.each do |sub|
|
27
|
-
Dir.chdir sub
|
28
|
-
puts "==> *进入#{sub}:".yellow
|
25
|
+
foreach_module {
|
29
26
|
system "git #{cmd}"
|
30
|
-
|
31
|
-
end
|
27
|
+
}
|
32
28
|
|
33
29
|
puts '==> *进入主工程:'.yellow
|
34
30
|
system "git #{cmd}"
|
data/lib/ggsm/flow/merge.rb
CHANGED
@@ -11,13 +11,11 @@ module GGSM
|
|
11
11
|
|
12
12
|
arry_conflict = []
|
13
13
|
|
14
|
-
|
15
|
-
subs.each do |sub|
|
16
|
-
Dir.chdir sub
|
14
|
+
foreach_module {|sub|
|
17
15
|
process_merge(arry_conflict, sub, branch)
|
18
|
-
|
19
|
-
end
|
16
|
+
}
|
20
17
|
|
18
|
+
puts '==> 进入主工程:'.yellow
|
21
19
|
process_merge(arry_conflict, '主工程', branch)
|
22
20
|
puts "Modules执行:git merge #{branch}".blue
|
23
21
|
|
@@ -31,7 +29,6 @@ module GGSM
|
|
31
29
|
end
|
32
30
|
|
33
31
|
def process_merge(arry_conflict, module_name, branch)
|
34
|
-
puts "==> 进入#{module_name}:".yellow
|
35
32
|
result_merge = `git merge #{branch}`
|
36
33
|
puts result_merge
|
37
34
|
|
data/lib/ggsm/flow/start.rb
CHANGED
@@ -32,17 +32,13 @@ module GGSM
|
|
32
32
|
return
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
subs.each do |sub|
|
37
|
-
Dir.chdir sub
|
38
|
-
puts "==> 进入#{sub}:".yellow
|
35
|
+
foreach_module {|sub|
|
39
36
|
need_stash = try_stash
|
40
37
|
system "git checkout -b #{branch}"
|
41
38
|
if need_stash
|
42
39
|
stash_pop(arry_conflict, sub)
|
43
40
|
end
|
44
|
-
|
45
|
-
end
|
41
|
+
}
|
46
42
|
|
47
43
|
if arry_conflict.size > 0
|
48
44
|
tip = "==> #{arry_conflict.size}个模块冲突:"
|
data/lib/ggsm/flow/switch.rb
CHANGED
@@ -27,29 +27,9 @@ module GGSM
|
|
27
27
|
|
28
28
|
sub_commits = get_submodule_commit
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
puts "==> 进入#{sub}:".yellow
|
34
|
-
need_stash = try_stash
|
35
|
-
result = system "git checkout #{branch}"
|
36
|
-
|
37
|
-
if result
|
38
|
-
commit = sub_commits.fetch(subs.index(sub));
|
39
|
-
commit_exist = system "git reset --hard #{commit}"
|
40
|
-
unless commit_exist
|
41
|
-
arry_commit_not_exist.push("==> #{sub}模块不存在远程commit:#{commit}")
|
42
|
-
end
|
43
|
-
else
|
44
|
-
puts "[#{sub}] 没有#{branch}分支,创建并切换到#{branch}".blue
|
45
|
-
system "git checkout -b #{branch}"
|
46
|
-
end
|
47
|
-
|
48
|
-
if need_stash
|
49
|
-
stash_pop(arry_conflict, sub)
|
50
|
-
end
|
51
|
-
Dir.chdir '..'
|
52
|
-
end
|
30
|
+
foreach_module {|sub, index|
|
31
|
+
process_switch(arry_commit_not_exist, arry_conflict, branch, index, sub, sub_commits)
|
32
|
+
}
|
53
33
|
|
54
34
|
if arry_conflict.size > 0
|
55
35
|
tip = "==> #{arry_conflict.size}个模块冲突:"
|
@@ -66,5 +46,25 @@ module GGSM
|
|
66
46
|
tip_contact_author
|
67
47
|
end
|
68
48
|
end
|
49
|
+
|
50
|
+
def process_switch(commit_not_exist, arry_conflict, branch, index, sub, sub_commits)
|
51
|
+
need_stash = try_stash
|
52
|
+
result = system "git checkout #{branch}"
|
53
|
+
|
54
|
+
if result
|
55
|
+
commit = sub_commits.fetch(index);
|
56
|
+
commit_exist = system "git reset --hard #{commit}"
|
57
|
+
unless commit_exist
|
58
|
+
commit_not_exist.push("==> #{sub}模块不存在远程commit:#{commit}")
|
59
|
+
end
|
60
|
+
else
|
61
|
+
puts "[#{sub}] 没有#{branch}分支,创建并切换到#{branch}".blue
|
62
|
+
system "git checkout -b #{branch}"
|
63
|
+
end
|
64
|
+
|
65
|
+
if need_stash
|
66
|
+
stash_pop(arry_conflict, sub)
|
67
|
+
end
|
68
|
+
end
|
69
69
|
end
|
70
70
|
end
|
data/lib/ggsm/util/submodule.rb
CHANGED
@@ -9,7 +9,7 @@ module GGSM
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def get_submodule
|
12
|
-
pattern = /(?<=\s)[0-9a-zA-Z]*(?=\s)/
|
12
|
+
pattern = /(?<=\s)[\/0-9a-zA-Z]*(?=\s)/
|
13
13
|
|
14
14
|
sub_status = `git submodule`
|
15
15
|
sub_status = sub_status.split(/\n/)
|
@@ -31,7 +31,13 @@ module GGSM
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def get_submodule_commit
|
34
|
-
|
34
|
+
sub_tree = 'git ls-tree HEAD | grep "160000"'
|
35
|
+
sub_commits = `#{sub_tree}`
|
36
|
+
if sub_commits.strip == '' && (File.directory? 'submodules')
|
37
|
+
Dir.chdir 'submodules'
|
38
|
+
sub_commits = `#{sub_tree}`
|
39
|
+
Dir.chdir '..'
|
40
|
+
end
|
35
41
|
pattern = /(?<=\s)[0-9a-zA-Z]{40}(?=\s)/
|
36
42
|
sub_commits = sub_commits.split(/\n/)
|
37
43
|
result = []
|
@@ -44,6 +50,7 @@ module GGSM
|
|
44
50
|
|
45
51
|
def check_un_commit_code
|
46
52
|
subs = get_submodule
|
53
|
+
project_path = Dir.pwd
|
47
54
|
subs.each do |sub|
|
48
55
|
Dir.chdir sub
|
49
56
|
status = `git status --ignore-submodules | grep 'nothing to commit'`
|
@@ -51,7 +58,7 @@ module GGSM
|
|
51
58
|
puts "#{sub} 有未提交的代码".red
|
52
59
|
exit 1
|
53
60
|
end
|
54
|
-
Dir.chdir
|
61
|
+
Dir.chdir project_path
|
55
62
|
end
|
56
63
|
|
57
64
|
status = `git status --ignore-submodules | grep 'nothing to commit'`
|
@@ -61,6 +68,17 @@ module GGSM
|
|
61
68
|
end
|
62
69
|
end
|
63
70
|
|
71
|
+
def foreach_module
|
72
|
+
subs = get_submodule
|
73
|
+
project_path = Dir.pwd
|
74
|
+
subs.each do |sub|
|
75
|
+
Dir.chdir sub
|
76
|
+
puts "==> 进入#{sub}:".yellow
|
77
|
+
yield sub, subs.index(sub)
|
78
|
+
Dir.chdir project_path
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
64
82
|
def get_current_branch
|
65
83
|
`git branch | grep "*"`.split('* ')[1].split("\n")[0]
|
66
84
|
end
|
data/lib/ggsm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ggsm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YoKey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|