dngg 0.0.1
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 +7 -0
- data/.gitignore +8 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +25 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dngg.gemspec +32 -0
- data/lib/dngg.rb +77 -0
- data/lib/dngg/command/delete.rb +57 -0
- data/lib/dngg/command/finish.rb +86 -0
- data/lib/dngg/command/foreach.rb +35 -0
- data/lib/dngg/command/merge.rb +108 -0
- data/lib/dngg/command/mr.rb +133 -0
- data/lib/dngg/command/start.rb +62 -0
- data/lib/dngg/command/switch.rb +76 -0
- data/lib/dngg/command/sync.rb +19 -0
- data/lib/dngg/hook/commit-msg +21 -0
- data/lib/dngg/hook/hooks.rb +52 -0
- data/lib/dngg/hook/pre-commit +54 -0
- data/lib/dngg/mr/email.rb +22 -0
- data/lib/dngg/mr/token.rb +21 -0
- data/lib/dngg/util/stash.rb +20 -0
- data/lib/dngg/util/submodule.rb +184 -0
- data/lib/dngg/version.rb +3 -0
- data/lib/res/install_billow.sh +33 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d89252c4d511fbf2c7d1430f96f988258fd30e01f472b0752d25ecafc4605314
|
4
|
+
data.tar.gz: 0d3e6baa8f093d8fd35a79e80ceb691cddec7f07e1a4ae55ab6b2bd51994ee5e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f9061d9ee4d13281d26b8c0cbed1d3be5838b3dd97545168e415d7fe85fa532dcdbbbe44a93a7bbd3eb01d3bd568552f93ec33ad1bf95d16ac45dc9711bc30c6
|
7
|
+
data.tar.gz: 45a01ba0259eef2ccf01e6db69f2a0c5d3c1de35e51d21dfa2236bbffb588a052e04308c0947eac91fa85e7c7418e7ad08ccd4341344651edd2d1fd0f2a534c2
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
dngg (0.0.1)
|
5
|
+
colorize (= 0.8.1)
|
6
|
+
oj (= 3.8.0)
|
7
|
+
thor (= 1.0.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
colorize (0.8.1)
|
13
|
+
oj (3.8.0)
|
14
|
+
rake (13.0.6)
|
15
|
+
thor (1.0.0)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
universal-darwin-19
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
dngg!
|
22
|
+
rake (~> 13.0)
|
23
|
+
|
24
|
+
BUNDLED WITH
|
25
|
+
2.2.23
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Dngg
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dngg`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'dngg'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install dngg
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dngg.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
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/bin/setup
ADDED
data/dngg.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "dngg/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'dngg'
|
8
|
+
spec.version = DNGG::VERSION
|
9
|
+
spec.authors = 'iSnow'
|
10
|
+
spec.email = 'schnee1109@163.com'
|
11
|
+
|
12
|
+
spec.summary = 'dngg'
|
13
|
+
spec.description = 'A submodule tools for Guang-Teams'
|
14
|
+
spec.homepage = 'http://rubygems.org/gems/dngg'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
|
26
|
+
# spec.add_development_dependency 'bundler', '~> 1.14'
|
27
|
+
# spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
|
29
|
+
spec.add_dependency 'thor', '1.0.0'
|
30
|
+
spec.add_dependency 'colorize', '0.8.1'
|
31
|
+
spec.add_dependency 'oj', '3.8.0'
|
32
|
+
end
|
data/lib/dngg.rb
ADDED
@@ -0,0 +1,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
|
+
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
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative '../util/submodule'
|
2
|
+
require_relative '../util/stash'
|
3
|
+
|
4
|
+
module DNGG
|
5
|
+
module Delete
|
6
|
+
include Submodule
|
7
|
+
include Stash
|
8
|
+
|
9
|
+
def delete_flow(branch, remote, all)
|
10
|
+
check_submodule
|
11
|
+
|
12
|
+
puts '==> 进入主工程:'.yellow
|
13
|
+
|
14
|
+
delete_branch(all, branch, remote)
|
15
|
+
|
16
|
+
foreach_module {
|
17
|
+
delete_branch(all, branch, remote)
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete_branch(all, branch, remote)
|
22
|
+
if branch == get_current_branch
|
23
|
+
puts "无法删除当前所在分支:#{branch},请switch其他分支后再执行\"dngg delete\"".red
|
24
|
+
exit 0
|
25
|
+
end
|
26
|
+
|
27
|
+
if all
|
28
|
+
delete_local_branch(branch)
|
29
|
+
delete_remote_branch(branch)
|
30
|
+
elsif remote
|
31
|
+
delete_remote_branch(branch)
|
32
|
+
else
|
33
|
+
delete_local_branch(branch)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def delete_local_branch(branch)
|
38
|
+
if `git branch | grep -e '\s|*#{branch}$'`.strip == ''
|
39
|
+
puts "warning: branch '#{branch}' not found"
|
40
|
+
else
|
41
|
+
info = `git branch -D #{branch}`
|
42
|
+
if info.strip != ''
|
43
|
+
puts "✓ #{info}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def delete_remote_branch(branch)
|
49
|
+
if `git branch -r | grep -e '\s|*origin/#{branch}$'`.strip == ''
|
50
|
+
puts "warning: remote branch '#{branch}' not found"
|
51
|
+
else
|
52
|
+
system "git push origin -d #{branch}"
|
53
|
+
`git fetch -p origin`
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require_relative '../util/submodule'
|
3
|
+
|
4
|
+
module DNGG
|
5
|
+
module Finish
|
6
|
+
include Submodule
|
7
|
+
|
8
|
+
def finish_flow(force)
|
9
|
+
check_submodule
|
10
|
+
|
11
|
+
foreach_module {
|
12
|
+
process_finish(false)
|
13
|
+
}
|
14
|
+
|
15
|
+
puts '==> 进入主工程:'.yellow
|
16
|
+
process_finish(force, get_main_project_msg)
|
17
|
+
|
18
|
+
puts 'Modules执行:git add & commit & push'.blue
|
19
|
+
end
|
20
|
+
|
21
|
+
def process_finish(force, msg='')
|
22
|
+
system 'git add .'
|
23
|
+
|
24
|
+
branch = get_current_branch
|
25
|
+
if branch.include?('rebas')
|
26
|
+
system 'git rebase --continue'
|
27
|
+
else
|
28
|
+
stage = `git diff --cached --name-only`.strip
|
29
|
+
if stage == ''
|
30
|
+
`git commit`
|
31
|
+
else
|
32
|
+
if msg == ''
|
33
|
+
result = system 'git commit'
|
34
|
+
else
|
35
|
+
result = system "git commit -m \"#{msg}\""
|
36
|
+
end
|
37
|
+
unless result
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
`git push -u origin #{get_current_branch} #{force ? '-f' : ''}`
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_main_project_msg()
|
47
|
+
system 'git add .'
|
48
|
+
|
49
|
+
pattern = /[A-Z]\s*(.*)/
|
50
|
+
result = `git status -s | grep -e '[A-Z].*'`.split(/\n/).delete_if do |r|
|
51
|
+
r == ''
|
52
|
+
end
|
53
|
+
modified = []
|
54
|
+
result.each do |r|
|
55
|
+
if match = r.match(pattern)
|
56
|
+
module_name = match[1].strip
|
57
|
+
if is_submodule(module_name)
|
58
|
+
modified.push(match[1].strip)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
whole_files = `git status -s`.split(/\n/).delete_if do |w|
|
64
|
+
w == ''
|
65
|
+
end
|
66
|
+
return '' if whole_files.length != modified.length
|
67
|
+
|
68
|
+
outputs = ''
|
69
|
+
modified.each_with_index do |m, index|
|
70
|
+
msg = get_lastest_msg_of_module(m)
|
71
|
+
outputs += msg.insert(msg.index(':') + 1, "[#{get_module_name(m)}]")
|
72
|
+
if index != modified.length - 1
|
73
|
+
outputs += "\n"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
puts outputs
|
78
|
+
outputs
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_module_name(module_name)
|
82
|
+
module_name.split(/\//).last.downcase
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require_relative '../util/submodule'
|
3
|
+
require_relative '../util/stash'
|
4
|
+
|
5
|
+
module DNGG
|
6
|
+
module Foreach
|
7
|
+
include Submodule
|
8
|
+
include Stash
|
9
|
+
|
10
|
+
def foreach_flow(*commands)
|
11
|
+
check_submodule
|
12
|
+
|
13
|
+
cmd = ''
|
14
|
+
if commands.size == 0
|
15
|
+
puts '请输入正确git命令 foreach [<commands>...]'.red
|
16
|
+
return
|
17
|
+
elsif commands.fetch(0) == 'git'
|
18
|
+
commands.delete_at(0)
|
19
|
+
end
|
20
|
+
|
21
|
+
commands.each do |arg|
|
22
|
+
cmd = "#{cmd} #{arg}"
|
23
|
+
end
|
24
|
+
|
25
|
+
foreach_module {
|
26
|
+
system "git #{cmd}"
|
27
|
+
}
|
28
|
+
|
29
|
+
puts '==> *进入主工程:'.yellow
|
30
|
+
system "git #{cmd}"
|
31
|
+
|
32
|
+
puts "Modules执行:git#{cmd}".blue
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require_relative '../util/submodule'
|
3
|
+
|
4
|
+
module DNGG
|
5
|
+
module Merge
|
6
|
+
include Submodule
|
7
|
+
|
8
|
+
def merge_flow(branch, force_rebase)
|
9
|
+
check_submodule
|
10
|
+
check_un_commit_code
|
11
|
+
|
12
|
+
arry_conflict = []
|
13
|
+
|
14
|
+
foreach_module {|sub|
|
15
|
+
if branch.start_with?('origin/')
|
16
|
+
`git fetch | grep 'ignored'`
|
17
|
+
end
|
18
|
+
process_merge(arry_conflict, sub, branch)
|
19
|
+
}
|
20
|
+
|
21
|
+
puts '==> 进入主工程:'.yellow
|
22
|
+
|
23
|
+
main_rebase = false
|
24
|
+
if force_rebase
|
25
|
+
main_rebase = true
|
26
|
+
end
|
27
|
+
|
28
|
+
if branch.start_with?('origin/')
|
29
|
+
`git fetch | grep 'ignored'`
|
30
|
+
end
|
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
|
39
|
+
|
40
|
+
if arry_conflict.size > 0
|
41
|
+
tip = "==> #{arry_conflict.size}个模块冲突:"
|
42
|
+
arry_conflict.reverse.each do |sub|
|
43
|
+
tip = "#{tip} #{sub}"
|
44
|
+
end
|
45
|
+
puts tip.red
|
46
|
+
puts "Tip: 当你解决冲突后,执行\"git add .\",如需推送远程,在主工程执行\"dngg finish\"".blue
|
47
|
+
else
|
48
|
+
|
49
|
+
if main_rebase
|
50
|
+
puts "Tip: 如需推送远程,执行\"dngg finish -f|--force\"".blue
|
51
|
+
else
|
52
|
+
puts "Tip: 如需推送远程,执行\"dngg finish\"".blue
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def process_merge(arry_conflict, module_name, branch)
|
58
|
+
result_merge = `git merge #{branch}`
|
59
|
+
puts result_merge
|
60
|
+
|
61
|
+
if result_merge.include? 'Merge conflict'
|
62
|
+
arry_conflict.push(module_name)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def process_rebase(arry_conflict, branch)
|
67
|
+
result_merge = `git rebase #{branch}`
|
68
|
+
puts result_merge
|
69
|
+
|
70
|
+
if result_merge.include? 'Merge conflict'
|
71
|
+
arry_conflict.push('主工程')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def need_rebase(branch)
|
76
|
+
pattern = /[0-9a-z]{7}(?=\s)/
|
77
|
+
current_branch = get_current_branch
|
78
|
+
|
79
|
+
can_rebase(current_branch) {|remote|
|
80
|
+
diff_logs = `git log --oneline #{branch}..#{current_branch}`.split("\n").reverse
|
81
|
+
|
82
|
+
if diff_logs.length > 0
|
83
|
+
commit = pattern.match(diff_logs[0].strip)[0]
|
84
|
+
result = `git log #{remote}/#{current_branch} |grep #{commit}`
|
85
|
+
if `git log --oneline #{current_branch}..#{branch}`.split("\n").length > 0 && result.strip != ''
|
86
|
+
return false
|
87
|
+
end
|
88
|
+
end
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
def can_rebase(current_branch)
|
93
|
+
remote = `git config --get branch.#{current_branch}.remote`
|
94
|
+
|
95
|
+
if remote == ''
|
96
|
+
`git branch -r`.split("\n").each do |branch|
|
97
|
+
if branch.strip == "origin/#{current_branch}"
|
98
|
+
remote = 'origin'
|
99
|
+
yield remote
|
100
|
+
end
|
101
|
+
end
|
102
|
+
else
|
103
|
+
yield remote
|
104
|
+
end
|
105
|
+
true
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require 'oj'
|
3
|
+
require 'net/http'
|
4
|
+
require_relative '../util/submodule'
|
5
|
+
require_relative '../mr/token'
|
6
|
+
require_relative '../mr/email'
|
7
|
+
|
8
|
+
module DNGG
|
9
|
+
module MR
|
10
|
+
include Submodule
|
11
|
+
include Token
|
12
|
+
include Email
|
13
|
+
|
14
|
+
@@current_branch = ''
|
15
|
+
@@target_branch = ''
|
16
|
+
@@pwd = ''
|
17
|
+
@@token = ''
|
18
|
+
@@msg = ''
|
19
|
+
@@urls = {}
|
20
|
+
@@user = ''
|
21
|
+
|
22
|
+
def mr_flow(target_branch, msg)
|
23
|
+
check_submodule(false)
|
24
|
+
|
25
|
+
@@current_branch = get_current_branch
|
26
|
+
@@target_branch = target_branch
|
27
|
+
|
28
|
+
if target_branch.start_with?('origin/')
|
29
|
+
@@target_branch = target_branch.split('origin/')[1]
|
30
|
+
end
|
31
|
+
|
32
|
+
@@pwd = Dir.pwd
|
33
|
+
@@token = init_check_token
|
34
|
+
@@msg = msg
|
35
|
+
|
36
|
+
foreach_module {|sub|
|
37
|
+
create_mr(sub)
|
38
|
+
}
|
39
|
+
|
40
|
+
puts '==> 进入主工程:'.yellow
|
41
|
+
create_mr('主工程')
|
42
|
+
|
43
|
+
content = ''
|
44
|
+
@@urls.each do |sub, url|
|
45
|
+
content = " #{content}\n #{sub}: #{url}"
|
46
|
+
end
|
47
|
+
|
48
|
+
if content != ''
|
49
|
+
send_email(@@user, @@msg, content)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def init_check_token
|
54
|
+
token = ''
|
55
|
+
path = '.git/dngg/TOKEN'
|
56
|
+
unless check_token
|
57
|
+
system "vim #{path}"
|
58
|
+
|
59
|
+
result = IO.read(path).split('# 请输入GitLab private-token')
|
60
|
+
|
61
|
+
if result.length > 1
|
62
|
+
token = result[0]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if token == ''
|
67
|
+
token = IO.read(path).split('# 请输入GitLab private-token')[0]
|
68
|
+
end
|
69
|
+
|
70
|
+
if token == ''
|
71
|
+
puts '请输入GitLab private-token'.red
|
72
|
+
exit 1
|
73
|
+
end
|
74
|
+
|
75
|
+
return token
|
76
|
+
end
|
77
|
+
|
78
|
+
def create_mr(sub)
|
79
|
+
current_branch_head_commit = get_head_commit("origin/#{@@current_branch}").chomp
|
80
|
+
|
81
|
+
if current_branch_head_commit!="origin/#{@@current_branch}" && # 判断远程分支是否存在
|
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)
|
85
|
+
result = `git remote -v | grep push`
|
86
|
+
project_name = result.split('.com/')[1]
|
87
|
+
if project_name == nil || project_name.strip == ''
|
88
|
+
project_name = result.split('.com:')[1]
|
89
|
+
end
|
90
|
+
|
91
|
+
if project_name != nil
|
92
|
+
project_name = project_name.split('.git')[0].gsub('/', '%2F')
|
93
|
+
|
94
|
+
begin
|
95
|
+
params = {}
|
96
|
+
params['source_branch'] = @@current_branch
|
97
|
+
params['target_branch'] = @@target_branch
|
98
|
+
params['title'] = @@msg
|
99
|
+
# params['remove_source_branch'] = true
|
100
|
+
uri = URI.parse("https://git.souche-inc.com/api/v4/projects/#{project_name}/merge_requests?private_token=#{@@token}")
|
101
|
+
response = Net::HTTP.post_form(uri, params)
|
102
|
+
result = Oj.load(response.body)
|
103
|
+
|
104
|
+
case response
|
105
|
+
when Net::HTTPSuccess then
|
106
|
+
mr_url = result['web_url']
|
107
|
+
|
108
|
+
if @@user == ''
|
109
|
+
@@user = result['author']['username']
|
110
|
+
end
|
111
|
+
|
112
|
+
if mr_url != nil
|
113
|
+
@@urls[sub] = mr_url
|
114
|
+
puts mr_url.blue
|
115
|
+
end
|
116
|
+
when Net::HTTPConflict then
|
117
|
+
puts 'Merge Request已存在!'
|
118
|
+
when Net::HTTPNotFound, Net::HTTPUnauthorized
|
119
|
+
Dir.chdir @@pwd
|
120
|
+
`rm -rf .git/dngg/TOKEN`
|
121
|
+
@@token = init_check_token
|
122
|
+
create_mr(sub)
|
123
|
+
return
|
124
|
+
end
|
125
|
+
rescue => e
|
126
|
+
puts "error: #{e}".red
|
127
|
+
exit 1
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require_relative '../util/submodule'
|
3
|
+
require_relative '../util/stash'
|
4
|
+
|
5
|
+
module DNGG
|
6
|
+
module Start
|
7
|
+
include Submodule
|
8
|
+
include Stash
|
9
|
+
|
10
|
+
def dd(x)
|
11
|
+
puts 89
|
12
|
+
end
|
13
|
+
|
14
|
+
def start_flow(branch, action)
|
15
|
+
check_submodule
|
16
|
+
|
17
|
+
puts '==> 进入主工程:'.yellow
|
18
|
+
|
19
|
+
arry_conflict = []
|
20
|
+
current_branch = get_current_branch
|
21
|
+
|
22
|
+
need_stash = try_stash
|
23
|
+
if action.start_with?('origin/')
|
24
|
+
need_fetch = `git fetch`
|
25
|
+
if need_fetch != ''
|
26
|
+
`git submodule foreach git fetch | grep 'ignored'`
|
27
|
+
end
|
28
|
+
end
|
29
|
+
result = system "git checkout -b #{branch} #{action}"
|
30
|
+
if need_stash
|
31
|
+
stash_pop(arry_conflict, '主工程')
|
32
|
+
end
|
33
|
+
|
34
|
+
unless result
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
38
|
+
result = system 'git submodule update --init --recursive'
|
39
|
+
unless result
|
40
|
+
tip_contact_author
|
41
|
+
`git checkout #{current_branch};git branch -D #{branch}`
|
42
|
+
return
|
43
|
+
end
|
44
|
+
|
45
|
+
foreach_module {|sub|
|
46
|
+
need_stash = try_stash
|
47
|
+
system "git checkout -b #{branch}"
|
48
|
+
if need_stash
|
49
|
+
stash_pop(arry_conflict, sub)
|
50
|
+
end
|
51
|
+
}
|
52
|
+
|
53
|
+
if arry_conflict.size > 0
|
54
|
+
tip = "==> #{arry_conflict.size}个模块冲突:"
|
55
|
+
arry_conflict.each do |sub|
|
56
|
+
tip = "#{tip} #{sub}"
|
57
|
+
end
|
58
|
+
puts tip.red
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require_relative '../util/submodule'
|
3
|
+
require_relative '../util/stash'
|
4
|
+
|
5
|
+
module DNGG
|
6
|
+
module Switch
|
7
|
+
include Submodule
|
8
|
+
include Stash
|
9
|
+
|
10
|
+
def switch_flow(branch, is_sync = false)
|
11
|
+
check_submodule
|
12
|
+
check_submodule_status(is_sync)
|
13
|
+
|
14
|
+
puts '==> 进入主工程:'.yellow
|
15
|
+
|
16
|
+
arry_conflict = []
|
17
|
+
arry_commit_not_exist = []
|
18
|
+
|
19
|
+
need_stash = try_stash
|
20
|
+
`git checkout #{branch}`; result=$?.success?
|
21
|
+
|
22
|
+
if need_stash
|
23
|
+
stash_pop(arry_conflict, '主工程')
|
24
|
+
end
|
25
|
+
|
26
|
+
unless result
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
sub_commits = get_submodule_commit
|
31
|
+
|
32
|
+
foreach_module {|sub, index|
|
33
|
+
if is_sync
|
34
|
+
`git fetch | grep 'ignored'`
|
35
|
+
end
|
36
|
+
process_switch(arry_commit_not_exist, arry_conflict, branch, index, sub, sub_commits)
|
37
|
+
}
|
38
|
+
|
39
|
+
if arry_conflict.size > 0
|
40
|
+
tip = "==> #{arry_conflict.size}个模块冲突:"
|
41
|
+
arry_conflict.each do |sub|
|
42
|
+
tip = "#{tip} #{sub}"
|
43
|
+
end
|
44
|
+
puts tip.red
|
45
|
+
end
|
46
|
+
|
47
|
+
if arry_commit_not_exist.size > 0
|
48
|
+
arry_commit_not_exist.each do |tip|
|
49
|
+
puts tip.red
|
50
|
+
end
|
51
|
+
tip_contact_author
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def process_switch(commit_not_exist, arry_conflict, branch, index, sub, sub_commits)
|
56
|
+
need_stash = try_stash
|
57
|
+
|
58
|
+
`git checkout #{branch}`; result=$?.success?
|
59
|
+
|
60
|
+
if result
|
61
|
+
commit = sub_commits.fetch(index);
|
62
|
+
`git reset --hard #{commit}`; result=$?.success?
|
63
|
+
unless result
|
64
|
+
commit_not_exist.push("==> #{sub}模块不存在远程commit:#{commit}")
|
65
|
+
end
|
66
|
+
else
|
67
|
+
puts "[#{sub}] 没有#{branch}分支,创建并切换到#{branch}".blue
|
68
|
+
system "git checkout -b #{branch}"
|
69
|
+
end
|
70
|
+
|
71
|
+
if need_stash
|
72
|
+
stash_pop(arry_conflict, sub)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require_relative 'switch'
|
3
|
+
|
4
|
+
module DNGG
|
5
|
+
module Sync
|
6
|
+
include Switch
|
7
|
+
|
8
|
+
def sync_flow
|
9
|
+
check_submodule
|
10
|
+
|
11
|
+
result = system 'git pull'
|
12
|
+
unless result
|
13
|
+
return
|
14
|
+
end
|
15
|
+
|
16
|
+
switch_flow(get_current_branch, true)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'colorize'
|
3
|
+
|
4
|
+
@msg = IO.read(ARGV[0]).force_encoding('UTF-8')
|
5
|
+
|
6
|
+
def commit_check
|
7
|
+
standards = %w(fix: fix: feat: feat: style: style: doc: doc: docs: docs: ref: ref: refactor: refactor: chore: chore: test: test: Merge merge Revert revert)
|
8
|
+
standards.each do |standard|
|
9
|
+
check(standard)
|
10
|
+
end
|
11
|
+
puts '====> commit message不符合规范,请查看规范'.red
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
|
15
|
+
def check(keyword)
|
16
|
+
if @msg.start_with? keyword
|
17
|
+
exit 0
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
commit_check
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module DNGG
|
2
|
+
module Hooks
|
3
|
+
def check_hooks
|
4
|
+
if update_hooks
|
5
|
+
install_billow
|
6
|
+
subs = get_submodule
|
7
|
+
subs.each do |sub|
|
8
|
+
cp_hooks(sub)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
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
|
+
def update_hooks
|
19
|
+
version = `dngg v`
|
20
|
+
ggsm_path = '.git/dngg'
|
21
|
+
unless File.exist?(ggsm_path)
|
22
|
+
Dir.mkdir(ggsm_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
config_path = "#{ggsm_path}/VERSION"
|
26
|
+
target_path = '.git/hooks'
|
27
|
+
|
28
|
+
if !File.exist?(config_path) || version != IO.read(config_path)
|
29
|
+
cp_files(target_path)
|
30
|
+
|
31
|
+
file = File.new(config_path, 'w')
|
32
|
+
file << version
|
33
|
+
file.close
|
34
|
+
|
35
|
+
puts '已更新Hooks'.blue
|
36
|
+
return true
|
37
|
+
end
|
38
|
+
false
|
39
|
+
end
|
40
|
+
|
41
|
+
def cp_hooks(sub)
|
42
|
+
target_path = ".git/modules/#{sub}/hooks"
|
43
|
+
cp_files(target_path)
|
44
|
+
end
|
45
|
+
|
46
|
+
def cp_files(target_path)
|
47
|
+
path = `gem which dngg`.split('/dngg.rb')[0]
|
48
|
+
`cp #{path}/dngg/hook/commit-msg #{target_path}/commit-msg`
|
49
|
+
`cp #{path}/dngg/hook/pre-commit #{target_path}/pre-commit`
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'colorize'
|
3
|
+
|
4
|
+
def switch_dir
|
5
|
+
if File.directory?('.git')
|
6
|
+
return
|
7
|
+
end
|
8
|
+
|
9
|
+
Dir.chdir '..'
|
10
|
+
switch_dir
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
stage = `git diff --cached --name-only`.strip
|
15
|
+
if stage == ''
|
16
|
+
exit 0
|
17
|
+
end
|
18
|
+
|
19
|
+
@pass = true
|
20
|
+
|
21
|
+
files = stage.split("\n")
|
22
|
+
|
23
|
+
count = 0
|
24
|
+
|
25
|
+
files.each do |file|
|
26
|
+
if File.extname(file) == '.java'
|
27
|
+
|
28
|
+
current_path = Dir.pwd
|
29
|
+
switch_dir
|
30
|
+
|
31
|
+
result = `java -jar #{Dir.pwd}/_script/checkstyle-7.0.jar -c #{Dir.pwd}/_script/checkstyle.xml #{Dir.pwd}/#{file}`
|
32
|
+
result = result.gsub("Starting audit...\n", '')
|
33
|
+
result = result.gsub("Audit done.\n", '')
|
34
|
+
result = result.force_encoding('UTF-8')
|
35
|
+
|
36
|
+
if result.include?('WARN') || result.include?('ERROR')
|
37
|
+
count = count + 1
|
38
|
+
puts "#{count}、 #{result}\n".red
|
39
|
+
@pass = false
|
40
|
+
elsif result.strip != ''
|
41
|
+
puts result
|
42
|
+
end
|
43
|
+
|
44
|
+
Dir.chdir current_path
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
unless @pass
|
49
|
+
exit 1
|
50
|
+
end
|
51
|
+
rescue => e
|
52
|
+
puts "error: #{e}".red
|
53
|
+
exit 1
|
54
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'net/smtp'
|
3
|
+
|
4
|
+
module DNGG
|
5
|
+
module Email
|
6
|
+
def send_email(user,title,msg)
|
7
|
+
message = <<END_OF_MESSAGE
|
8
|
+
DNGG Merge Request <android.dev@guang.com>
|
9
|
+
To: Guang Android Team
|
10
|
+
Subject: [#{user}] #{title}
|
11
|
+
|
12
|
+
#{msg}
|
13
|
+
END_OF_MESSAGE
|
14
|
+
|
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'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module DNGG
|
2
|
+
module Token
|
3
|
+
def check_token
|
4
|
+
ggsm_path = '.git/dngg'
|
5
|
+
unless File.exist?(ggsm_path)
|
6
|
+
Dir.mkdir(ggsm_path)
|
7
|
+
end
|
8
|
+
|
9
|
+
config_path = "#{ggsm_path}/TOKEN"
|
10
|
+
|
11
|
+
if !File.exist?(config_path) || '' == IO.read(config_path).strip || IO.readlines(config_path)[0].strip == ''
|
12
|
+
file = File.new(config_path, 'w')
|
13
|
+
file << "\n# 请输入GitLab private-token"
|
14
|
+
file.close
|
15
|
+
return false
|
16
|
+
end
|
17
|
+
|
18
|
+
return true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module DNGG
|
2
|
+
module Stash
|
3
|
+
def try_stash
|
4
|
+
status = `git status --ignore-submodules | grep 'nothing to commit'`
|
5
|
+
need_stash = false
|
6
|
+
if status.strip == ''
|
7
|
+
need_stash = true
|
8
|
+
`git stash`
|
9
|
+
end
|
10
|
+
need_stash
|
11
|
+
end
|
12
|
+
|
13
|
+
def stash_pop(arry_conflict, module_name)
|
14
|
+
stash_pop = `git stash pop | grep 'CONFLICT'`
|
15
|
+
if stash_pop.strip != ''
|
16
|
+
arry_conflict.push(module_name)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require_relative '../hook/hooks'
|
2
|
+
|
3
|
+
module DNGG
|
4
|
+
module Submodule
|
5
|
+
include Hooks
|
6
|
+
|
7
|
+
def check_submodule(check=true)
|
8
|
+
sub_str = `git submodule`
|
9
|
+
if check && sub_str.empty?
|
10
|
+
puts '所在目录工程下不存在Submodule,请检查所在目录!'.red
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
|
14
|
+
correct_dir
|
15
|
+
check_hooks
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_submodule
|
19
|
+
pattern = /(?<=\s)[\/0-9a-zA-Z]*(?=\s)/
|
20
|
+
|
21
|
+
sub_status = `git submodule`
|
22
|
+
sub_status = sub_status.split(/\n/)
|
23
|
+
match = pattern.match(sub_status[0])
|
24
|
+
|
25
|
+
if match==nil
|
26
|
+
puts '==> 初始化子模块'.yellow
|
27
|
+
`git submodule update --init --recursive`
|
28
|
+
sub_status = `git submodule`
|
29
|
+
sub_status = sub_status.split(/\n/)
|
30
|
+
end
|
31
|
+
|
32
|
+
result = []
|
33
|
+
sub_status.each do |sub|
|
34
|
+
match = pattern.match(sub.strip)
|
35
|
+
result.push(match[0])
|
36
|
+
end
|
37
|
+
result
|
38
|
+
end
|
39
|
+
|
40
|
+
def check_submodule_status(is_sync)
|
41
|
+
modified_sub = get_modified_submodule
|
42
|
+
if !is_sync && modified_sub.size > 0
|
43
|
+
subs = ''
|
44
|
+
modified_sub.each do |sub|
|
45
|
+
subs = "#{sub} , #{subs}"
|
46
|
+
end
|
47
|
+
puts "\n存在未跟踪的子模块提交: #{subs[0...subs.size-2]} \n\n请选择操作:\n1 丢弃子模块的改动
|
48
|
+
2 追踪子模块(仅追踪子模块)\n3 追踪所有改变\n4 取消".red
|
49
|
+
|
50
|
+
input = STDIN.gets.chomp.upcase
|
51
|
+
if input == '1'
|
52
|
+
elsif input == '2'
|
53
|
+
add = 'git add'
|
54
|
+
modified_sub.each do |sub|
|
55
|
+
add = "#{add} #{sub}"
|
56
|
+
end
|
57
|
+
system "#{add};git commit"
|
58
|
+
elsif input == '3'
|
59
|
+
system 'git add .;git commit'
|
60
|
+
else
|
61
|
+
puts '==> 取消操作'.blue
|
62
|
+
exit 0
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_modified_submodule
|
68
|
+
result = []
|
69
|
+
|
70
|
+
status = `git status -s`.split(/\n/)
|
71
|
+
subs = get_submodule
|
72
|
+
|
73
|
+
status.each do |sub|
|
74
|
+
array_name = sub.split(' ')
|
75
|
+
name = array_name[array_name.size-1]
|
76
|
+
if subs.include? name
|
77
|
+
result.push(name)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
result
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_submodule_commit
|
84
|
+
sub_tree = 'git ls-tree HEAD | grep "160000"'
|
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
|
91
|
+
pattern = /(?<=\s)[0-9a-zA-Z]{40}(?=\s)/
|
92
|
+
sub_commits = sub_commits.split(/\n/)
|
93
|
+
result = []
|
94
|
+
sub_commits.each do |sub|
|
95
|
+
match = pattern.match(sub.strip)
|
96
|
+
result.push(match[0][0...7])
|
97
|
+
end
|
98
|
+
result
|
99
|
+
end
|
100
|
+
|
101
|
+
def check_un_commit_code
|
102
|
+
subs = get_submodule
|
103
|
+
project_path = Dir.pwd
|
104
|
+
subs.each do |sub|
|
105
|
+
Dir.chdir sub
|
106
|
+
status = `git status --ignore-submodules | grep 'nothing to commit'`
|
107
|
+
if status.strip == ''
|
108
|
+
puts "#{sub} 有未提交的代码".red
|
109
|
+
exit 1
|
110
|
+
end
|
111
|
+
Dir.chdir project_path
|
112
|
+
end
|
113
|
+
|
114
|
+
status = `git status --ignore-submodules | grep 'nothing to commit'`
|
115
|
+
if status.strip == ''
|
116
|
+
puts '主工程 有未提交的代码'.red
|
117
|
+
exit 1
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def foreach_module
|
122
|
+
subs = get_submodule
|
123
|
+
project_path = Dir.pwd
|
124
|
+
subs.each do |sub|
|
125
|
+
Dir.chdir sub
|
126
|
+
puts "==> 进入#{sub}:".yellow
|
127
|
+
yield sub, subs.index(sub)
|
128
|
+
Dir.chdir project_path
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def get_lastest_msg_of_module(module_name)
|
133
|
+
msg = ''
|
134
|
+
project_path = Dir.pwd
|
135
|
+
if is_submodule(module_name)
|
136
|
+
Dir.chdir module_name
|
137
|
+
msg = get_lastest_msg_not_merge
|
138
|
+
Dir.chdir project_path
|
139
|
+
end
|
140
|
+
msg
|
141
|
+
end
|
142
|
+
|
143
|
+
def is_submodule(module_name)
|
144
|
+
get_submodule.include?(module_name)
|
145
|
+
end
|
146
|
+
|
147
|
+
def get_lastest_msg_not_merge
|
148
|
+
depth = 1
|
149
|
+
while (msg = get_lastest_msg(depth)).start_with?('Merge branch') do
|
150
|
+
depth += 1
|
151
|
+
end
|
152
|
+
msg
|
153
|
+
end
|
154
|
+
|
155
|
+
def get_lastest_msg(depth)
|
156
|
+
msg = `git log --format=%B -n #{depth}`.split(/\n\n/)
|
157
|
+
msg[depth - 1].strip
|
158
|
+
end
|
159
|
+
|
160
|
+
def get_current_branch
|
161
|
+
`git branch | grep "*"`.split('* ')[1].split("\n")[0]
|
162
|
+
end
|
163
|
+
|
164
|
+
def tip_contact_author
|
165
|
+
latest_commit = `git log test -1 --oneline | grep ''`.split(' ')[0]
|
166
|
+
author = `git show #{latest_commit}|grep "Author:"`.chomp
|
167
|
+
puts "请联系#{author} 推送远程缺失的commit".red
|
168
|
+
end
|
169
|
+
|
170
|
+
def correct_dir
|
171
|
+
if File.exist?('.git')
|
172
|
+
return
|
173
|
+
end
|
174
|
+
|
175
|
+
Dir.chdir '..'
|
176
|
+
correct_dir
|
177
|
+
end
|
178
|
+
|
179
|
+
# 获取#{branch}上HEAD的commit id
|
180
|
+
def get_head_commit(branch)
|
181
|
+
`git rev-parse #{branch}`
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
data/lib/dngg/version.rb
ADDED
@@ -0,0 +1,33 @@
|
|
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
|
+
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dngg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- iSnow
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: colorize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.8.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.8.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: oj
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.8.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.8.0
|
55
|
+
description: A submodule tools for Guang-Teams
|
56
|
+
email: schnee1109@163.com
|
57
|
+
executables:
|
58
|
+
- console
|
59
|
+
- setup
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- dngg.gemspec
|
71
|
+
- lib/dngg.rb
|
72
|
+
- lib/dngg/command/delete.rb
|
73
|
+
- lib/dngg/command/finish.rb
|
74
|
+
- lib/dngg/command/foreach.rb
|
75
|
+
- lib/dngg/command/merge.rb
|
76
|
+
- lib/dngg/command/mr.rb
|
77
|
+
- lib/dngg/command/start.rb
|
78
|
+
- lib/dngg/command/switch.rb
|
79
|
+
- lib/dngg/command/sync.rb
|
80
|
+
- lib/dngg/hook/commit-msg
|
81
|
+
- lib/dngg/hook/hooks.rb
|
82
|
+
- lib/dngg/hook/pre-commit
|
83
|
+
- lib/dngg/mr/email.rb
|
84
|
+
- lib/dngg/mr/token.rb
|
85
|
+
- lib/dngg/util/stash.rb
|
86
|
+
- lib/dngg/util/submodule.rb
|
87
|
+
- lib/dngg/version.rb
|
88
|
+
- lib/res/install_billow.sh
|
89
|
+
homepage: http://rubygems.org/gems/dngg
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubygems_version: 3.0.3
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: dngg
|
112
|
+
test_files: []
|