ggsm 1.4.0 → 1.5.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
  SHA1:
3
- metadata.gz: 6047a2466f671d94d9ed1632af90fc1362c24a98
4
- data.tar.gz: e171938265ea8db94e4b051e7ece45d1a9dec9e1
3
+ metadata.gz: a1815f21d14345d4fb9eaee303c6d9db195b5741
4
+ data.tar.gz: 89df586f2ed17db5c1d1bb8e07cff935d8d321da
5
5
  SHA512:
6
- metadata.gz: c2d39d480055c9ffcbc9ff9dc604ec7b6e635fc709b4c696a0a06e79fa1334729edff7a5d2f8bfe1fef1e1a47a9c2fa54e65391921c709aacded640453e0de91
7
- data.tar.gz: be44fcddb27f8b8691f563124fc3dc3187db7993cabaa90479916ac53ec516f0b579e715fb4f997394ae813edf94a1e51ceb94cb9a91c7902ea3a7b6beb28949
6
+ metadata.gz: 59e2f95a29e0d224f9864d8284a4550db3195c1ca200c77c42d6cc273acddbfd631ab88e8f739b4d56c61af8343ab8018d911d8b00ec299a646a32d9ddea2f12
7
+ data.tar.gz: 472f1d7bfbf0959cacf90b3e9559a56a0705b5e6f9cde4c0ebd9c0a8a540ee5b1dc2b39aaaffc4514c7b3a61c1ee5bac9590a75ebf72c994b4f362c8debab79f
data/bin/ggsm CHANGED
@@ -2,6 +2,7 @@
2
2
  # encoding: utf-8
3
3
 
4
4
  require_relative '../lib/ggsm'
5
+ require_relative '../lib/ggsm/version'
5
6
 
6
7
  begin
7
8
  GGSM::Cli.start ARGV
@@ -16,7 +16,7 @@ module GGSM
16
16
  }
17
17
 
18
18
  puts '==> 进入主工程:'.yellow
19
- process_merge(arry_conflict, '主工程', branch)
19
+ process_rebase(arry_conflict, branch)
20
20
  puts "Modules执行:git merge #{branch}".blue
21
21
 
22
22
  if arry_conflict.size > 0
@@ -36,5 +36,14 @@ module GGSM
36
36
  arry_conflict.push(module_name)
37
37
  end
38
38
  end
39
+
40
+ def process_rebase(arry_conflict, branch)
41
+ result_merge = `git rebase #{branch}`
42
+ puts result_merge
43
+
44
+ if result_merge.include? 'Merge conflict'
45
+ arry_conflict.push('主工程')
46
+ end
47
+ end
39
48
  end
40
49
  end
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby
2
+ require 'colorize'
3
+
4
+ @msg = IO.read(ARGV[0]).force_encoding('UTF-8')
5
+
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)
8
+ standards.each do |standard|
9
+ check(standard)
10
+ end
11
+ puts '==> commit message不符合规范!'.red
12
+ exit 1
13
+ end
14
+
15
+ def check(keyword)
16
+ if @msg.start_with? keyword
17
+ exit 0
18
+ end
19
+ end
20
+
21
+ commit_check
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/ruby
2
+ require 'colorize'
3
+
4
+ def switch_dir
5
+ if File.directory?('.git')
6
+ return
7
+ end
8
+
9
+ Dir.chdir '..'
10
+ switch_dir
11
+ end
12
+
13
+ begin
14
+ stage = `git diff --cached --name-only`.strip
15
+ if stage == ''
16
+ exit 0
17
+ end
18
+
19
+ @pass = true
20
+
21
+ files = stage.split("\n")
22
+
23
+ count = 0
24
+
25
+ files.each do |file|
26
+ if File.extname(file) == '.java'
27
+
28
+ current_path = Dir.pwd
29
+ switch_dir
30
+
31
+ result = `java -jar #{Dir.pwd}/_script/checkstyle-7.0.jar -c #{Dir.pwd}/_script/checkstyle.xml #{Dir.pwd}/#{file}`
32
+ result = result.gsub("Starting audit...\n", '')
33
+ result = result.gsub("Audit done.\n", '')
34
+
35
+ if result.include?('WARN') || result.include?('ERROR')
36
+ count = count + 1
37
+ puts "#{count}、 #{result}\n".red
38
+ @pass = false
39
+ elsif result.strip != ''
40
+ puts result
41
+ end
42
+
43
+ Dir.chdir current_path
44
+ end
45
+ end
46
+
47
+ unless @pass
48
+ exit 1
49
+ end
50
+ rescue => e
51
+ puts "error: #{e}".red
52
+ exit 1
53
+ end
@@ -6,6 +6,9 @@ module GGSM
6
6
  puts '所在目录工程下不存在Submodule,请检查所在目录!'.red
7
7
  exit 1
8
8
  end
9
+
10
+ switch_dir
11
+ check_hooks
9
12
  end
10
13
 
11
14
  def get_submodule
@@ -88,5 +91,47 @@ module GGSM
88
91
  author = `git show #{latest_commit}|grep "Author:"`.chomp
89
92
  puts "请联系#{author} 推送远程缺失的commit".red
90
93
  end
94
+
95
+ def switch_dir
96
+ if File.exist?('.git')
97
+ return
98
+ end
99
+
100
+ Dir.chdir '..'
101
+ switch_dir
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
135
+ end
91
136
  end
92
137
  end
data/lib/ggsm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module GGSM
2
- VERSION = '1.4.0'
2
+ VERSION = '1.5.0'
3
3
  end
data/lib/ggsm.rb CHANGED
@@ -47,8 +47,8 @@ module GGSM
47
47
  foreach_flow(*commands)
48
48
  end
49
49
 
50
- desc 'merge [<branch>]', 'Merge,开发完成后执行'
51
- def merge(branch='origin/dev')
50
+ desc 'merge <branch>', 'Merge,开发完成后执行'
51
+ def merge(branch)
52
52
  merge_flow(branch)
53
53
  end
54
54
 
@@ -56,5 +56,10 @@ module GGSM
56
56
  def finish
57
57
  finish_flow
58
58
  end
59
+
60
+ desc '[v|version]', '查看版本'
61
+ def version
62
+ puts VERSION
63
+ end
59
64
  end
60
65
  end
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.0
4
+ version: 1.5.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-22 00:00:00.000000000 Z
11
+ date: 2017-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,6 +92,8 @@ files:
92
92
  - lib/ggsm/flow/start.rb
93
93
  - lib/ggsm/flow/switch.rb
94
94
  - lib/ggsm/flow/sync.rb
95
+ - lib/ggsm/hook/commit-msg
96
+ - lib/ggsm/hook/pre-commit
95
97
  - lib/ggsm/util/stash.rb
96
98
  - lib/ggsm/util/submodule.rb
97
99
  - lib/ggsm/version.rb