dngg 0.0.4 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a44d21d8641e361b5ffa3b19b5b4198ef7da899f21364f0042e33df241ddfe0
4
- data.tar.gz: 6023c6a7996eea055fc8cd3cd90af3db0023b74d04d5b90dbd130f3593eec63e
3
+ metadata.gz: be0dd6c12a2cc8781b3c7828027f5b67bd83f78daf766f9f6a8d4ebf6bf54fc1
4
+ data.tar.gz: 31cbcf1c0f1d1f038fdefb657fe20ee90e6e8ca0530ee78c0124b056f9048dc5
5
5
  SHA512:
6
- metadata.gz: b7603c1f0d4a837a8985ee257d2da193b28b7316c19a493d49f22c003e2f8aad4a2ee4a323eb969cb43996f4b52629ae10bdb507f1c76f5f34a33b03a6ce5dec
7
- data.tar.gz: fe2b17bccd2ed52dd0cb45a42e6703dde4ed6186243ad88498483cc263228994e717adfde40bbb56d3c4d23d986461cdb90feb75554f6066395f4970f31223ca
6
+ metadata.gz: 3b1579fde8500f989b65ed7099a23219191ff47b3db321c084c341ed53be6e208e6091e2e5f09b50dbcf2cbab6136c5c55d86e17604a48d38b29153a83f3a90f
7
+ data.tar.gz: 83f6698ec58560949c3c628856f080cf007f7fc4b25b42ebb36bc957a8ac88cd1de7f1d5c5221b20aeec91059c26a85737808f1a73b40ec21a74e05909e08df3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dngg (0.0.4)
4
+ dngg (0.0.8)
5
5
  colorize (= 0.8.1)
6
6
  oj (= 3.8.0)
7
7
  thor (= 1.0.0)
data/lib/dngg.rb CHANGED
@@ -20,6 +20,10 @@ module DNGG
20
20
  include Finish
21
21
  include MR
22
22
 
23
+ def self.exit_on_failure?
24
+ true
25
+ end
26
+
23
27
  desc 'sync', '当前分支同步(拉取)远程代码'
24
28
  def sync
25
29
  sync_flow
@@ -30,8 +34,8 @@ module DNGG
30
34
  start_flow(branch, action)
31
35
  end
32
36
 
33
- desc 'merge <branch> [-r|--rebase]', 'Merge,开发完成后执行; -r:主工程强制rebase'
34
- option :rebase, :default => false, :type => :boolean, aliases: '-r'
37
+ desc 'merge <branch>', 'Merge,开发完成后执行'
38
+ # option :rebase, :default => false, :type => :boolean, aliases: '-r'
35
39
  def merge(branch)
36
40
  rebase = options[:rebase]
37
41
  merge_flow(branch, rebase)
@@ -73,5 +77,4 @@ module DNGG
73
77
  puts VERSION
74
78
  end
75
79
  end
76
- # Cli.start(ARGV)
77
80
  end
@@ -59,16 +59,16 @@ module DNGG
59
59
  end
60
60
  end
61
61
  end
62
-
63
62
  whole_files = `git status -s`.split(/\n/).delete_if do |w|
64
63
  w == ''
65
64
  end
66
65
  return '' if whole_files.length != modified.length
67
-
68
66
  outputs = ''
69
67
  modified.each_with_index do |m, index|
70
68
  msg = get_lastest_msg_of_module(m)
71
- outputs += msg.insert(msg.index(':') + 1, "[#{get_module_name(m)}]")
69
+ if msg.index(':')
70
+ outputs += msg.insert(msg.index(':') + 1, "[#{get_module_name(m)}]")
71
+ end
72
72
  if index != modified.length - 1
73
73
  outputs += "\n"
74
74
  end
@@ -79,7 +79,7 @@ module DNGG
79
79
  end
80
80
 
81
81
  def get_module_name(module_name)
82
- module_name.split(/\//).last.downcase
82
+ module_name.split(/\//).last
83
83
  end
84
84
 
85
85
  end
@@ -29,13 +29,14 @@ module DNGG
29
29
  `git fetch | grep 'ignored'`
30
30
  end
31
31
 
32
- if need_rebase(branch) || force_rebase
33
- process_rebase(arry_conflict, branch)
34
- puts 'Tip: 主工程rebase模式'.blue
35
- else
36
- process_merge(arry_conflict, '主工程', branch)
37
- puts 'Tip: 主工程merge模式'.blue
38
- end
32
+ # if need_rebase(branch) || force_rebase
33
+ # process_rebase(arry_conflict, branch)
34
+ # puts 'Tip: 主工程rebase模式'.blue
35
+ # else
36
+ # process_merge(arry_conflict, '主工程', branch)
37
+ # puts 'Tip: 主工程merge模式'.blue
38
+ # end
39
+ process_merge(arry_conflict, '主工程', branch)
39
40
 
40
41
  if arry_conflict.size > 0
41
42
  tip = "==> #{arry_conflict.size}个模块冲突:"
@@ -80,8 +80,8 @@ module DNGG
80
80
 
81
81
  if current_branch_head_commit!="origin/#{@@current_branch}" && # 判断远程分支是否存在
82
82
  get_head_commit("origin/#{@@current_branch}") != get_head_commit("origin/#{@@target_branch}")
83
- # origin git@git.souche.com:Destiny_Android/Destiny_Android.git (push)
84
- # origin http://git.souche.com/Destiny_Android/Mine.git (push)
83
+ # origin git@gitlab.qima-inc.com:guang-mobile-shop/AiGuangMaxApp.git (push)
84
+ # origin https://gitlab.qima-inc.com/guang-mobile-shop/AiGuangMaxApp.git (push)
85
85
  result = `git remote -v | grep push`
86
86
  project_name = result.split('.com/')[1]
87
87
  if project_name == nil || project_name.strip == ''
@@ -90,14 +90,13 @@ module DNGG
90
90
 
91
91
  if project_name != nil
92
92
  project_name = project_name.split('.git')[0].gsub('/', '%2F')
93
-
94
93
  begin
95
94
  params = {}
96
95
  params['source_branch'] = @@current_branch
97
96
  params['target_branch'] = @@target_branch
98
97
  params['title'] = @@msg
99
98
  # params['remove_source_branch'] = true
100
- uri = URI.parse("https://git.souche-inc.com/api/v4/projects/#{project_name}/merge_requests?private_token=#{@@token}")
99
+ uri = URI.parse("https://gitlab.qima-inc.com/api/v4/projects/#{project_name}/merge_requests?private_token=#{@@token}")
101
100
  response = Net::HTTP.post_form(uri, params)
102
101
  result = Oj.load(response.body)
103
102
 
@@ -121,6 +120,8 @@ module DNGG
121
120
  @@token = init_check_token
122
121
  create_mr(sub)
123
122
  return
123
+ when Net::HTTPForbidden then
124
+ puts response.body.red
124
125
  end
125
126
  rescue => e
126
127
  puts "error: #{e}".red
@@ -8,7 +8,7 @@ def commit_check
8
8
  standards.each do |standard|
9
9
  check(standard)
10
10
  end
11
- puts '====> commit message不符合规范,请查看规范'.red
11
+ puts '====> commit message不符合规范,请查看规范 https://naxg5qz90v.feishu.cn/wiki/wikcnGAC0ayqRw5SSyj6QFQESKb'.red
12
12
  exit 1
13
13
  end
14
14
 
data/lib/dngg/mr/email.rb CHANGED
@@ -4,18 +4,21 @@ require 'net/smtp'
4
4
  module DNGG
5
5
  module Email
6
6
  def send_email(user,title,msg)
7
+ user_mail = `git config user.email`
7
8
  message = <<END_OF_MESSAGE
8
- DNGG Merge Request <android.dev@guang.com>
9
+ DNGG Merge Request <team_android@aiguang.com>
10
+ From: #{user}
9
11
  To: Guang Android Team
10
12
  Subject: [#{user}] #{title}
11
13
 
12
14
  #{msg}
15
+
13
16
  END_OF_MESSAGE
14
17
 
15
- Net::SMTP.start('smtp.exmail.qq.com', 25, 'iSnow',
16
- 'zhuruixue@aiguang.com', 'wwL9RS9cLeBxv7co') do |smtp|
17
- smtp.send_message message,
18
- 'android.dev@guang.com'
18
+ Net::SMTP.start('smtp.exmail.qq.com',25,'zhuruixue',
19
+ 'zhuruixue@aiguang.com','wwL9RS9cLeBxv7co', :plain) do |smtp|
20
+ smtp.send_message message, 'zhuruixue@aiguang.com',
21
+ 'team_android@aiguang.com'
19
22
  end
20
23
  end
21
24
  end
@@ -32,6 +32,10 @@ module DNGG
32
32
  result = []
33
33
  sub_status.each do |sub|
34
34
  match = pattern.match(sub.strip)
35
+ unless match
36
+ puts `pwd`,"====>>>子模块id #{sub}拉取异常!!! 执行 git submodule 检查".red
37
+ next
38
+ end
35
39
  result.push(match[0])
36
40
  end
37
41
  result
@@ -83,11 +87,11 @@ module DNGG
83
87
  def get_submodule_commit
84
88
  sub_tree = 'git ls-tree HEAD | grep "160000"'
85
89
  sub_commits = `#{sub_tree}`
86
- if sub_commits.strip == '' && (File.directory? 'submodules')
87
- Dir.chdir 'submodules'
88
- sub_commits = `#{sub_tree}`
89
- Dir.chdir '..'
90
- end
90
+ # if sub_commits.strip == '' && (File.directory? 'submodules')
91
+ # Dir.chdir 'submodules'
92
+ # sub_commits = `#{sub_tree}`
93
+ # Dir.chdir '..'
94
+ # end
91
95
  pattern = /(?<=\s)[0-9a-zA-Z]{40}(?=\s)/
92
96
  sub_commits = sub_commits.split(/\n/)
93
97
  result = []
@@ -144,16 +148,17 @@ module DNGG
144
148
  get_submodule.include?(module_name)
145
149
  end
146
150
 
151
+ # 寻找上次merge之后的commit消息
147
152
  def get_lastest_msg_not_merge
148
153
  depth = 1
149
- while (msg = get_lastest_msg(depth)).start_with?('Merge branch') do
154
+ while (msg = get_lastest_msg(depth)).start_with?('Merge ') do
150
155
  depth += 1
151
156
  end
152
157
  msg
153
158
  end
154
159
 
155
160
  def get_lastest_msg(depth)
156
- msg = `git log --format=%B -n #{depth}`.split(/\n\n/)
161
+ msg = `git log --oneline --format=%B -n #{depth}`.split(/\n\n/)
157
162
  msg[depth - 1].strip
158
163
  end
159
164
 
data/lib/dngg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DNGG
2
- VERSION = '0.0.4'
3
- end
2
+ VERSION = '0.0.8'
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dngg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - iSnow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-26 00:00:00.000000000 Z
11
+ date: 2021-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor