ggsm 1.5.1 → 1.6.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/lib/ggsm.rb +27 -22
- data/lib/ggsm/{flow → command}/delete.rb +0 -0
- data/lib/ggsm/{flow → command}/finish.rb +0 -0
- data/lib/ggsm/{flow → command}/foreach.rb +0 -0
- data/lib/ggsm/{flow → command}/merge.rb +0 -0
- data/lib/ggsm/{flow → command}/start.rb +0 -0
- data/lib/ggsm/{flow → command}/switch.rb +2 -1
- data/lib/ggsm/{flow → command}/sync.rb +1 -1
- data/lib/ggsm/hook/commit-msg +1 -1
- data/lib/ggsm/hook/pre-commit +1 -0
- data/lib/ggsm/util/hooks.rb +46 -0
- data/lib/ggsm/util/submodule.rb +50 -36
- data/lib/ggsm/version.rb +1 -1
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69c805930e864b62f6d3d204382434aaa2834597
|
4
|
+
data.tar.gz: 76ccc110964243679acb139cd88a79bc3deb342a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 217a55a09c089548b21ab2cb2e593b743a890ad2a7375c63f7a37b1c1d638c357d9d5246adbbfe948a7ade9dc91b2b8a08a8e889277b9f39f903ac42e19b70e6
|
7
|
+
data.tar.gz: 3715f2f5a477b083bfcac5e9cbfe7f1739bc51b71e104d29faf97f66f793371220f0b4b7a1e4df150d99e5dc07f7d371b85fcde71e08c148e41bccdc0570e325
|
data/lib/ggsm.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require_relative 'ggsm/version'
|
3
|
-
require_relative 'ggsm/
|
4
|
-
require_relative 'ggsm/
|
5
|
-
require_relative 'ggsm/
|
6
|
-
require_relative 'ggsm/
|
7
|
-
require_relative 'ggsm/
|
8
|
-
require_relative 'ggsm/
|
9
|
-
require_relative 'ggsm/
|
3
|
+
require_relative 'ggsm/command/start'
|
4
|
+
require_relative 'ggsm/command/sync'
|
5
|
+
require_relative 'ggsm/command/switch'
|
6
|
+
require_relative 'ggsm/command/delete'
|
7
|
+
require_relative 'ggsm/command/foreach'
|
8
|
+
require_relative 'ggsm/command/merge'
|
9
|
+
require_relative 'ggsm/command/finish'
|
10
10
|
|
11
11
|
module GGSM
|
12
12
|
class Cli < Thor
|
@@ -18,21 +18,31 @@ module GGSM
|
|
18
18
|
include Merge
|
19
19
|
include Finish
|
20
20
|
|
21
|
+
desc 'sync', '当前分支同步(拉取)远程代码'
|
22
|
+
def sync
|
23
|
+
sync_flow
|
24
|
+
end
|
25
|
+
|
21
26
|
desc 'start <branch> [<commit>] [<origin>]', '检出新分支,新功能、修bug务必使用该命令'
|
22
27
|
def start(branch, action='')
|
23
28
|
start_flow(branch, action)
|
24
29
|
end
|
25
30
|
|
31
|
+
desc 'merge <branch>', 'Merge,开发完成后执行'
|
32
|
+
def merge(branch)
|
33
|
+
merge_flow(branch)
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'finish', 'Merge后并解决冲突后执行'
|
37
|
+
def finish
|
38
|
+
finish_flow
|
39
|
+
end
|
40
|
+
|
26
41
|
desc 'switch <branch>', '切换分支'
|
27
42
|
def switch(branch)
|
28
43
|
switch_flow(branch)
|
29
44
|
end
|
30
45
|
|
31
|
-
desc 'sync', '当前分支同步(拉取)远程代码'
|
32
|
-
def sync
|
33
|
-
sync_flow
|
34
|
-
end
|
35
|
-
|
36
46
|
desc 'delete <branch> [-r|--remote] [-a|--all]', '删除指定分支'
|
37
47
|
option :remote, :default => false, :type => :boolean, aliases: '-r'
|
38
48
|
option :all, :default => false, :type => :boolean, aliases: '-a'
|
@@ -42,21 +52,16 @@ module GGSM
|
|
42
52
|
delete_flow(branch, remote, all)
|
43
53
|
end
|
44
54
|
|
55
|
+
desc 'status', '显示所有模块的状态'
|
56
|
+
def status
|
57
|
+
foreach('status')
|
58
|
+
end
|
59
|
+
|
45
60
|
desc 'foreach [<commands>...]', '所有模块执行git命令(foreach后跟git命令)'
|
46
61
|
def foreach(*commands)
|
47
62
|
foreach_flow(*commands)
|
48
63
|
end
|
49
64
|
|
50
|
-
desc 'merge <branch>', 'Merge,开发完成后执行'
|
51
|
-
def merge(branch)
|
52
|
-
merge_flow(branch)
|
53
|
-
end
|
54
|
-
|
55
|
-
desc 'finish', 'Merge后并解决冲突后执行'
|
56
|
-
def finish
|
57
|
-
finish_flow
|
58
|
-
end
|
59
|
-
|
60
65
|
desc '[v|version]', '查看版本'
|
61
66
|
def version
|
62
67
|
puts VERSION
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/ggsm/hook/commit-msg
CHANGED
@@ -4,7 +4,7 @@ require 'colorize'
|
|
4
4
|
@msg = IO.read(ARGV[0]).force_encoding('UTF-8')
|
5
5
|
|
6
6
|
def commit_check
|
7
|
-
standards = %w(fix: fix: feat: feat: style: style: doc: doc: docs: docs: ref: ref: refactor: refactor: chore: chore: test: test: Merge merge)
|
7
|
+
standards = %w(fix: fix: feat: feat: style: style: doc: doc: docs: docs: ref: ref: refactor: refactor: chore: chore: test: test: Merge merge Revert revert)
|
8
8
|
standards.each do |standard|
|
9
9
|
check(standard)
|
10
10
|
end
|
data/lib/ggsm/hook/pre-commit
CHANGED
@@ -31,6 +31,7 @@ begin
|
|
31
31
|
result = `java -jar #{Dir.pwd}/_script/checkstyle-7.0.jar -c #{Dir.pwd}/_script/checkstyle.xml #{Dir.pwd}/#{file}`
|
32
32
|
result = result.gsub("Starting audit...\n", '')
|
33
33
|
result = result.gsub("Audit done.\n", '')
|
34
|
+
result = result.force_encoding('UTF-8')
|
34
35
|
|
35
36
|
if result.include?('WARN') || result.include?('ERROR')
|
36
37
|
count = count + 1
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module GGSM
|
2
|
+
module Hooks
|
3
|
+
def check_hooks
|
4
|
+
if update_hooks
|
5
|
+
subs = get_submodule
|
6
|
+
subs.each do |sub|
|
7
|
+
cp_hooks(sub)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def update_hooks
|
13
|
+
version = `ggsm v`
|
14
|
+
ggsm_path = '.git/ggsm'
|
15
|
+
unless File.exist?(ggsm_path)
|
16
|
+
Dir.mkdir(ggsm_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
config_path = "#{ggsm_path}/VERSION"
|
20
|
+
target_path = '.git/hooks'
|
21
|
+
|
22
|
+
if !File.exist?(config_path) || version != IO.read(config_path)
|
23
|
+
cp_files(target_path)
|
24
|
+
|
25
|
+
file = File.new(config_path, 'w')
|
26
|
+
file << version
|
27
|
+
file.close
|
28
|
+
|
29
|
+
puts '已更新Hooks'.blue
|
30
|
+
return true
|
31
|
+
end
|
32
|
+
false
|
33
|
+
end
|
34
|
+
|
35
|
+
def cp_hooks(sub)
|
36
|
+
target_path = ".git/modules/#{sub}/hooks"
|
37
|
+
cp_files(target_path)
|
38
|
+
end
|
39
|
+
|
40
|
+
def cp_files(target_path)
|
41
|
+
path = `gem which ggsm`.split('/ggsm.rb')[0]
|
42
|
+
`cp #{path}/ggsm/hook/commit-msg #{target_path}/commit-msg`
|
43
|
+
`cp #{path}/ggsm/hook/pre-commit #{target_path}/pre-commit`
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/ggsm/util/submodule.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
require_relative 'hooks'
|
2
|
+
|
1
3
|
module GGSM
|
2
4
|
module Submodule
|
5
|
+
include Hooks
|
6
|
+
|
3
7
|
def check_submodule
|
4
8
|
sub_str = `git submodule`
|
5
9
|
if sub_str.empty?
|
@@ -7,7 +11,7 @@ module GGSM
|
|
7
11
|
exit 1
|
8
12
|
end
|
9
13
|
|
10
|
-
|
14
|
+
correct_dir
|
11
15
|
check_hooks
|
12
16
|
end
|
13
17
|
|
@@ -33,6 +37,49 @@ module GGSM
|
|
33
37
|
result
|
34
38
|
end
|
35
39
|
|
40
|
+
def check_submodule_status(is_sync)
|
41
|
+
modified_sub = get_modified_submodule
|
42
|
+
if !is_sync && modified_sub.size > 0
|
43
|
+
subs = ''
|
44
|
+
modified_sub.each do |sub|
|
45
|
+
subs = "#{sub} , #{subs}"
|
46
|
+
end
|
47
|
+
puts "\n存在未跟踪的子模块提交: #{subs[0...subs.size-2]} \n\n请选择操作:\n1 丢弃子模块的改动
|
48
|
+
2 追踪子模块(仅追踪子模块)\n3 追踪所有改变\n4 取消".red
|
49
|
+
|
50
|
+
input = STDIN.gets.chomp.upcase
|
51
|
+
if input == '1'
|
52
|
+
elsif input == '2'
|
53
|
+
add = 'git add'
|
54
|
+
modified_sub.each do |sub|
|
55
|
+
add = "#{add} #{sub}"
|
56
|
+
end
|
57
|
+
system "#{add};git commit"
|
58
|
+
elsif input == '3'
|
59
|
+
system 'git add .;git commit'
|
60
|
+
else
|
61
|
+
puts '==> 取消操作'.blue
|
62
|
+
return
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_modified_submodule
|
68
|
+
result = []
|
69
|
+
|
70
|
+
status = `git status -s`.split(/\n/)
|
71
|
+
subs = get_submodule
|
72
|
+
|
73
|
+
status.each do |sub|
|
74
|
+
array_name = sub.split(' ')
|
75
|
+
name = array_name[array_name.size-1]
|
76
|
+
if subs.include?name
|
77
|
+
result.push(name)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
result
|
81
|
+
end
|
82
|
+
|
36
83
|
def get_submodule_commit
|
37
84
|
sub_tree = 'git ls-tree HEAD | grep "160000"'
|
38
85
|
sub_commits = `#{sub_tree}`
|
@@ -92,46 +139,13 @@ module GGSM
|
|
92
139
|
puts "请联系#{author} 推送远程缺失的commit".red
|
93
140
|
end
|
94
141
|
|
95
|
-
def
|
142
|
+
def correct_dir
|
96
143
|
if File.exist?('.git')
|
97
144
|
return
|
98
145
|
end
|
99
146
|
|
100
147
|
Dir.chdir '..'
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
def check_hooks
|
105
|
-
version = `ggsm v`
|
106
|
-
subs = get_submodule
|
107
|
-
subs.each do |sub|
|
108
|
-
cp_hooks(version, sub)
|
109
|
-
end
|
110
|
-
cp_hooks(version, nil)
|
111
|
-
end
|
112
|
-
|
113
|
-
def cp_hooks(version, sub)
|
114
|
-
if File.exist?('.git')
|
115
|
-
if sub != nil
|
116
|
-
config_path = ".git/modules/#{sub}/hooks/ggsm"
|
117
|
-
else
|
118
|
-
config_path = '.git/hooks/ggsm'
|
119
|
-
end
|
120
|
-
target_path = config_path.split('/ggsm')[0]
|
121
|
-
if !File.exist?(config_path) || version != IO.read(config_path)
|
122
|
-
path = `gem which ggsm`.split('/ggsm.rb')[0]
|
123
|
-
`cp #{path}/ggsm/hook/commit-msg #{target_path}/commit-msg`
|
124
|
-
`cp #{path}/ggsm/hook/pre-commit #{target_path}/pre-commit`
|
125
|
-
|
126
|
-
file = File.new(config_path, 'w')
|
127
|
-
file << version
|
128
|
-
file.close
|
129
|
-
|
130
|
-
if sub == nil
|
131
|
-
puts '已更新Hooks'.blue
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
148
|
+
correct_dir
|
135
149
|
end
|
136
150
|
end
|
137
151
|
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.6.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-08-
|
11
|
+
date: 2017-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,15 +85,16 @@ files:
|
|
85
85
|
- bin/ggsm
|
86
86
|
- ggsm.gemspec
|
87
87
|
- lib/ggsm.rb
|
88
|
-
- lib/ggsm/
|
89
|
-
- lib/ggsm/
|
90
|
-
- lib/ggsm/
|
91
|
-
- lib/ggsm/
|
92
|
-
- lib/ggsm/
|
93
|
-
- lib/ggsm/
|
94
|
-
- lib/ggsm/
|
88
|
+
- lib/ggsm/command/delete.rb
|
89
|
+
- lib/ggsm/command/finish.rb
|
90
|
+
- lib/ggsm/command/foreach.rb
|
91
|
+
- lib/ggsm/command/merge.rb
|
92
|
+
- lib/ggsm/command/start.rb
|
93
|
+
- lib/ggsm/command/switch.rb
|
94
|
+
- lib/ggsm/command/sync.rb
|
95
95
|
- lib/ggsm/hook/commit-msg
|
96
96
|
- lib/ggsm/hook/pre-commit
|
97
|
+
- lib/ggsm/util/hooks.rb
|
97
98
|
- lib/ggsm/util/stash.rb
|
98
99
|
- lib/ggsm/util/submodule.rb
|
99
100
|
- lib/ggsm/version.rb
|