dngg 0.0.2 → 0.0.6

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
  SHA256:
3
- metadata.gz: dd9d121406a49a1a7dae5b56c5e81530773d993123db786f3121fd6e2d852cef
4
- data.tar.gz: 5243df3729a8099d5afce4fbfd4d89df0d54177df7bdefdf80c59652dcb8cdaf
3
+ metadata.gz: 2ecfeb442ed96915e6fdc9101590f01e2efe062593976b072cf298319781a9d7
4
+ data.tar.gz: 7a74ad2ec1d7ec59b18696ca68f8e01f3cf435e9fad1d38e8db0e18eac42a60e
5
5
  SHA512:
6
- metadata.gz: 8fe67c78d44ee0e0606a7759a35802a7551bf943c6505a5b16dd6e9e4d2757c30e6fa8f4706e97bc8125844345054d2b1093cefdf8dd86c27151537d809f5f50
7
- data.tar.gz: 42a2c2d243d42e84333d62658983d57c8226117ea410654e0e23b131a6b8f28b4e30ba1cd6d1a395009f52620d767fc302b3fd86389e72dc9f06afba72a1f8e6
6
+ metadata.gz: ae5244fd440c15209f5e0d40c8a77ad4c87a4e12aeae9cbcac792fa7f3846e6f2ec83589dbab9fbd6003eb1a4e3c08073b95d802c0193f3a9cc11245e65ee73b
7
+ data.tar.gz: 4d9bfb71b7254a58483437faf444b66efc39cc6ff3b66c14bf423a2615c3da27d697c5272cba80ac397b850d5d745afdda34a9dd3807773fb5dc7e9018e8ef64
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dngg (0.0.2)
4
+ dngg (0.0.6)
5
5
  colorize (= 0.8.1)
6
6
  oj (= 3.8.0)
7
7
  thor (= 1.0.0)
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
- desc 'sync', '当前分支同步(拉取)远程代码'
24
- def sync
25
- sync_flow
26
- end
27
-
28
- desc 'start <branch> [<commit>] [<origin>]', '检出新分支,新功能、修bug务必使用该命令'
29
- def start(branch, action='')
30
- start_flow(branch, action)
31
- end
32
-
33
- desc 'merge <branch> [-r|--rebase]', 'Merge,开发完成后执行; -r:主工程强制rebase'
34
- option :rebase, :default => false, :type => :boolean, aliases: '-r'
35
- def merge(branch)
36
- rebase = options[:rebase]
37
- merge_flow(branch, rebase)
38
- end
39
-
40
- desc 'finish [-f|--force]', 'Merge后并解决冲突后执行; -f:主工程强制推送'
41
- option :force, :default => false, :type => :boolean, aliases: '-f'
42
- def finish
43
- force = options[:force]
44
- finish_flow(force)
45
- end
46
-
47
- desc 'mr <branch> <title>', '创建MR'
48
- def mr(branch, title)
49
- mr_flow(branch, title)
50
- end
51
-
52
- desc 'switch <branch>', '切换分支'
53
- def switch(branch)
54
- switch_flow(branch)
55
- end
56
-
57
- desc 'delete <branch> [-r|--remote] [-a|--all]', '删除指定分支'
58
- option :remote, :default => false, :type => :boolean, aliases: '-r'
59
- option :all, :default => false, :type => :boolean, aliases: '-a'
60
- def delete(branch)
61
- remote = options[:remote]
62
- all = options[:all]
63
- delete_flow(branch, remote, all)
64
- end
65
-
66
- desc 'foreach [<commands>...]', '所有模块执行git命令(foreach后跟git命令)'
67
- def foreach(*commands)
68
- foreach_flow(*commands)
69
- end
70
-
71
- desc 'v', '查看版本'
72
- def version
73
- puts VERSION
74
- end
75
- end
76
- # Cli.start(ARGV)
77
- end
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
@@ -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
 
@@ -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 <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
@@ -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
- Dir.chdir 'submodules'
88
- sub_commits = `#{sub_tree}`
89
- Dir.chdir '..'
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 branch') do
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.2'
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.2
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-07-19 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
@@ -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__)
@@ -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
-