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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/dngg.rb +4 -1
- data/lib/dngg/command/finish.rb +4 -4
- data/lib/dngg/command/mr.rb +5 -4
- data/lib/dngg/hook/commit-msg +1 -1
- data/lib/dngg/mr/email.rb +8 -5
- data/lib/dngg/util/submodule.rb +12 -7
- data/lib/dngg/version.rb +2 -2
- metadata +2 -4
- data/bin/console +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5df153f7aa9a80914809d7f3915339d1a77579cb7acb572ffa5587258b6ca4d5
|
4
|
+
data.tar.gz: 6cef40653c132cf070b9b68a497992249d91dcaf3798934cc936f361562c6a9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8def88976670a26691caf0bce996473421ee685cb8e380a04357f832f04485133178b9305d6be6feb0b66bcd97e5a62ab85421597a49c5b696ef9b3627705722
|
7
|
+
data.tar.gz: cc732898c05e77720cb1c8353ddadb221fdbc3a4e9f893d3702f7ba2cdf63cc68947be41519bbb37345cc8003147b4743b7b55aa7d00bf11b8ee92c8fe569b9d
|
data/Gemfile.lock
CHANGED
data/lib/dngg.rb
CHANGED
data/lib/dngg/command/finish.rb
CHANGED
@@ -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
|
-
|
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
|
82
|
+
module_name.split(/\//).last
|
83
83
|
end
|
84
84
|
|
85
85
|
end
|
data/lib/dngg/command/mr.rb
CHANGED
@@ -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@
|
84
|
-
# origin
|
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://
|
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
|
data/lib/dngg/hook/commit-msg
CHANGED
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 <
|
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',
|
16
|
-
|
17
|
-
smtp.send_message message,
|
18
|
-
|
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
|
data/lib/dngg/util/submodule.rb
CHANGED
@@ -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
|
-
|
88
|
-
|
89
|
-
|
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
|
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
|
-
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.
|
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-
|
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__)
|