dngg 0.0.2 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/bin/dngg +6 -5
- data/lib/dngg.rb +80 -77
- 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/hook/hooks.rb +0 -6
- data/lib/dngg/mr/email.rb +8 -5
- data/lib/dngg/util/submodule.rb +8 -7
- data/lib/dngg/version.rb +2 -2
- metadata +2 -5
- data/bin/console +0 -14
- data/lib/res/install_billow.sh +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ecfeb442ed96915e6fdc9101590f01e2efe062593976b072cf298319781a9d7
|
4
|
+
data.tar.gz: 7a74ad2ec1d7ec59b18696ca68f8e01f3cf435e9fad1d38e8db0e18eac42a60e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae5244fd440c15209f5e0d40c8a77ad4c87a4e12aeae9cbcac792fa7f3846e6f2ec83589dbab9fbd6003eb1a4e3c08073b95d802c0193f3a9cc11245e65ee73b
|
7
|
+
data.tar.gz: 4d9bfb71b7254a58483437faf444b66efc39cc6ff3b66c14bf423a2615c3da27d697c5272cba80ac397b850d5d745afdda34a9dd3807773fb5dc7e9018e8ef64
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/bin/dngg
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# require_relative "../lib/dngg.rb"
|
3
2
|
|
4
|
-
set -euo pipefail
|
3
|
+
# set -euo pipefail
|
4
|
+
require_relative '../lib/dngg'
|
5
5
|
|
6
|
-
IFS=$'\n\t'
|
7
|
-
set -vx
|
6
|
+
# IFS=$'\n\t'
|
7
|
+
# set -vx
|
8
|
+
DNGG::Cli.start(ARGV)
|
8
9
|
|
9
|
-
bundle install
|
10
|
+
# bundle install
|
10
11
|
|
11
12
|
# Do any other automated setup that you need to do here
|
data/lib/dngg.rb
CHANGED
@@ -1,77 +1,80 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require_relative 'dngg/version'
|
3
|
-
require_relative 'dngg/command/start'
|
4
|
-
require_relative 'dngg/command/sync'
|
5
|
-
require_relative 'dngg/command/switch'
|
6
|
-
require_relative 'dngg/command/delete'
|
7
|
-
require_relative 'dngg/command/foreach'
|
8
|
-
require_relative 'dngg/command/merge'
|
9
|
-
require_relative 'dngg/command/finish'
|
10
|
-
require_relative 'dngg/command/mr'
|
11
|
-
|
12
|
-
module DNGG
|
13
|
-
class Cli < Thor
|
14
|
-
include Start
|
15
|
-
include Sync
|
16
|
-
include Switch
|
17
|
-
include Delete
|
18
|
-
include Foreach
|
19
|
-
include Merge
|
20
|
-
include Finish
|
21
|
-
include MR
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
1
|
+
require 'thor'
|
2
|
+
require_relative 'dngg/version'
|
3
|
+
require_relative 'dngg/command/start'
|
4
|
+
require_relative 'dngg/command/sync'
|
5
|
+
require_relative 'dngg/command/switch'
|
6
|
+
require_relative 'dngg/command/delete'
|
7
|
+
require_relative 'dngg/command/foreach'
|
8
|
+
require_relative 'dngg/command/merge'
|
9
|
+
require_relative 'dngg/command/finish'
|
10
|
+
require_relative 'dngg/command/mr'
|
11
|
+
|
12
|
+
module DNGG
|
13
|
+
class Cli < Thor
|
14
|
+
include Start
|
15
|
+
include Sync
|
16
|
+
include Switch
|
17
|
+
include Delete
|
18
|
+
include Foreach
|
19
|
+
include Merge
|
20
|
+
include Finish
|
21
|
+
include MR
|
22
|
+
|
23
|
+
def self.exit_on_failure?
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'sync', '当前分支同步(拉取)远程代码'
|
28
|
+
def sync
|
29
|
+
sync_flow
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'start <branch> [<commit>] [<origin>]', '检出新分支,新功能、修bug务必使用该命令'
|
33
|
+
def start(branch, action='')
|
34
|
+
start_flow(branch, action)
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'merge <branch> [-r|--rebase]', 'Merge,开发完成后执行; -r:主工程强制rebase'
|
38
|
+
option :rebase, :default => false, :type => :boolean, aliases: '-r'
|
39
|
+
def merge(branch)
|
40
|
+
rebase = options[:rebase]
|
41
|
+
merge_flow(branch, rebase)
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'finish [-f|--force]', 'Merge后并解决冲突后执行; -f:主工程强制推送'
|
45
|
+
option :force, :default => false, :type => :boolean, aliases: '-f'
|
46
|
+
def finish
|
47
|
+
force = options[:force]
|
48
|
+
finish_flow(force)
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'mr <branch> <title>', '创建MR'
|
52
|
+
def mr(branch, title)
|
53
|
+
mr_flow(branch, title)
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'switch <branch>', '切换分支'
|
57
|
+
def switch(branch)
|
58
|
+
switch_flow(branch)
|
59
|
+
end
|
60
|
+
|
61
|
+
desc 'delete <branch> [-r|--remote] [-a|--all]', '删除指定分支'
|
62
|
+
option :remote, :default => false, :type => :boolean, aliases: '-r'
|
63
|
+
option :all, :default => false, :type => :boolean, aliases: '-a'
|
64
|
+
def delete(branch)
|
65
|
+
remote = options[:remote]
|
66
|
+
all = options[:all]
|
67
|
+
delete_flow(branch, remote, all)
|
68
|
+
end
|
69
|
+
|
70
|
+
desc 'foreach [<commands>...]', '所有模块执行git命令(foreach后跟git命令)'
|
71
|
+
def foreach(*commands)
|
72
|
+
foreach_flow(*commands)
|
73
|
+
end
|
74
|
+
|
75
|
+
desc 'v', '查看版本'
|
76
|
+
def version
|
77
|
+
puts VERSION
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
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/hook/hooks.rb
CHANGED
@@ -2,7 +2,6 @@ module DNGG
|
|
2
2
|
module Hooks
|
3
3
|
def check_hooks
|
4
4
|
if update_hooks
|
5
|
-
install_billow
|
6
5
|
subs = get_submodule
|
7
6
|
subs.each do |sub|
|
8
7
|
cp_hooks(sub)
|
@@ -10,11 +9,6 @@ module DNGG
|
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
13
|
-
def install_billow
|
14
|
-
path = `gem which dngg`.split('/dngg.rb')[0]
|
15
|
-
`sudo sh #{path}/res/install_billow.sh`
|
16
|
-
end
|
17
|
-
|
18
12
|
def update_hooks
|
19
13
|
version = `dngg v`
|
20
14
|
ggsm_path = '.git/dngg'
|
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
@@ -83,11 +83,11 @@ module DNGG
|
|
83
83
|
def get_submodule_commit
|
84
84
|
sub_tree = 'git ls-tree HEAD | grep "160000"'
|
85
85
|
sub_commits = `#{sub_tree}`
|
86
|
-
if sub_commits.strip == '' && (File.directory? 'submodules')
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
86
|
+
# if sub_commits.strip == '' && (File.directory? 'submodules')
|
87
|
+
# Dir.chdir 'submodules'
|
88
|
+
# sub_commits = `#{sub_tree}`
|
89
|
+
# Dir.chdir '..'
|
90
|
+
# end
|
91
91
|
pattern = /(?<=\s)[0-9a-zA-Z]{40}(?=\s)/
|
92
92
|
sub_commits = sub_commits.split(/\n/)
|
93
93
|
result = []
|
@@ -144,16 +144,17 @@ module DNGG
|
|
144
144
|
get_submodule.include?(module_name)
|
145
145
|
end
|
146
146
|
|
147
|
+
# 寻找上次merge之后的commit消息
|
147
148
|
def get_lastest_msg_not_merge
|
148
149
|
depth = 1
|
149
|
-
while (msg = get_lastest_msg(depth)).start_with?('Merge
|
150
|
+
while (msg = get_lastest_msg(depth)).start_with?('Merge ') do
|
150
151
|
depth += 1
|
151
152
|
end
|
152
153
|
msg
|
153
154
|
end
|
154
155
|
|
155
156
|
def get_lastest_msg(depth)
|
156
|
-
msg = `git log --format=%B -n #{depth}`.split(/\n\n/)
|
157
|
+
msg = `git log --oneline --format=%B -n #{depth}`.split(/\n\n/)
|
157
158
|
msg[depth - 1].strip
|
158
159
|
end
|
159
160
|
|
data/lib/dngg/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module DNGG
|
2
|
-
VERSION = '0.0.
|
3
|
-
end
|
2
|
+
VERSION = '0.0.6'
|
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.6
|
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
|
@@ -85,7 +83,6 @@ files:
|
|
85
83
|
- lib/dngg/util/stash.rb
|
86
84
|
- lib/dngg/util/submodule.rb
|
87
85
|
- lib/dngg/version.rb
|
88
|
-
- lib/res/install_billow.sh
|
89
86
|
homepage: http://rubygems.org/gems/dngg
|
90
87
|
licenses:
|
91
88
|
- MIT
|
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__)
|
data/lib/res/install_billow.sh
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# # 下载
|
2
|
-
# curl -o ~/billow.zip http://7xq884.com1.z0.glb.clouddn.com/Billow.zip
|
3
|
-
|
4
|
-
# pushd ~/Library/Application\ Support
|
5
|
-
|
6
|
-
# # 解压到Application Support/AS
|
7
|
-
# for file in ./AndroidStudio*
|
8
|
-
# do
|
9
|
-
# if test -d $file
|
10
|
-
# then
|
11
|
-
# pushd ~/Library/Application\ Support/$file
|
12
|
-
# unzip -o ~/billow.zip
|
13
|
-
# popd
|
14
|
-
# fi
|
15
|
-
# done
|
16
|
-
|
17
|
-
# popd
|
18
|
-
|
19
|
-
# # 修改Preferences,开启插件
|
20
|
-
# for file in ~/Library/Preferences/AndroidStudio*
|
21
|
-
# do
|
22
|
-
# if test -d $file
|
23
|
-
# then
|
24
|
-
# sed '/^com.souche.plugin.billow/'d $file/disabled_plugins.txt > disabled_plugins_billow.txt
|
25
|
-
# cp disabled_plugins_billow.txt $file/disabled_plugins.txt
|
26
|
-
# rm -rf disabled_plugins_billow.txt
|
27
|
-
# fi
|
28
|
-
# done
|
29
|
-
|
30
|
-
# rm -rf ~/billow.zip
|
31
|
-
|
32
|
-
# echo Billow安装成功,请重新启动AndroidStudio
|
33
|
-
|