dngg 0.0.3 → 0.0.7

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: 7b591c218e98539ba3f3396920f3599df088792c7d462bcc9f7fba0de7508644
4
- data.tar.gz: d570f5aec0942c9d8a1ff09073c5542984bda92d67f9dd2af6e3564ae80264f2
3
+ metadata.gz: 5df153f7aa9a80914809d7f3915339d1a77579cb7acb572ffa5587258b6ca4d5
4
+ data.tar.gz: 6cef40653c132cf070b9b68a497992249d91dcaf3798934cc936f361562c6a9d
5
5
  SHA512:
6
- metadata.gz: 3ec388bb39d326b157c9a4cc9656637172a9dd524f64542608f803e4e858673a4bbf5e942d3a2e4b4e12c24bea1990d3ef4a0fdc7e8897305fea67a7aef1cf23
7
- data.tar.gz: de14584be918991a640729b5c1585d9f04f0946df917715736e06eb2b145fc72f776033267738ea5f7abd6df7d070ee9be6db785559ddda28cee7f9b9c6738e0
6
+ metadata.gz: 8def88976670a26691caf0bce996473421ee685cb8e380a04357f832f04485133178b9305d6be6feb0b66bcd97e5a62ab85421597a49c5b696ef9b3627705722
7
+ data.tar.gz: cc732898c05e77720cb1c8353ddadb221fdbc3a4e9f893d3702f7ba2cdf63cc68947be41519bbb37345cc8003147b4743b7b55aa7d00bf11b8ee92c8fe569b9d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dngg (0.0.3)
4
+ dngg (0.0.7)
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
@@ -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
@@ -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.3'
3
- end
2
+ VERSION = '0.0.7'
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.3
4
+ version: 0.0.7
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-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -55,7 +55,6 @@ dependencies:
55
55
  description: A submodule tools for Guang-Teams
56
56
  email: schnee1109@163.com
57
57
  executables:
58
- - console
59
58
  - dngg
60
59
  extensions: []
61
60
  extra_rdoc_files: []
@@ -65,7 +64,6 @@ files:
65
64
  - Gemfile.lock
66
65
  - README.md
67
66
  - Rakefile
68
- - bin/console
69
67
  - bin/dngg
70
68
  - dngg.gemspec
71
69
  - lib/dngg.rb
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "dngg"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)