ggsm 0.0.1 → 1.0.0
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 +4 -4
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +4 -6
- data/bin/ggsm +11 -2
- data/ggsm.gemspec +30 -0
- data/lib/ggsm.rb +48 -24
- data/lib/ggsm/flow/delete.rb +38 -0
- data/lib/ggsm/flow/foreach.rb +42 -0
- data/lib/ggsm/flow/start.rb +52 -0
- data/lib/ggsm/flow/switch.rb +60 -0
- data/lib/ggsm/flow/sync.rb +22 -0
- data/lib/ggsm/flow/update.rb +12 -0
- data/lib/ggsm/util/stash.rb +20 -0
- data/lib/ggsm/util/submodule.rb +37 -0
- data/lib/ggsm/version.rb +3 -0
- metadata +86 -13
- data/test/test_ggsm.rb +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fdb26eff5e32f1ba8b71d831c1882c6e8b1ece4a
|
|
4
|
+
data.tar.gz: c784dbf1527230dc28e27604e903230fe961d51b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7520bd496694396834e374671dc004762b132cf2c910cf58c03170355953375a6f4461e2831d6ec46174a3ada2dc206d9325d75a04d4a2e9b027587844e171a1
|
|
7
|
+
data.tar.gz: 4db64a146f5901380e24054fb4cae81e3afdb9167ddae0a4d1b184a27ed4d87dee29e2f1442ec073c14c831476fba7caaeafe9a018fc3092fa01a5a3569f5882
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at yokeyword@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 YoKey
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# GGSM
|
|
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/hex`. 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 'ggsm'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install hex
|
|
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. Then, run `rake spec` to run the tests. 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]/hex. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
41
|
+
|
data/Rakefile
CHANGED
data/bin/ggsm
CHANGED
data/ggsm.gemspec
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'ggsm/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'ggsm'
|
|
8
|
+
spec.version = GGSM::VERSION
|
|
9
|
+
spec.authors = ['YoKey']
|
|
10
|
+
spec.email = ['328903522@qq.com']
|
|
11
|
+
|
|
12
|
+
spec.summary = 'ggsm'
|
|
13
|
+
spec.description = 'A gem for Git Submodule'
|
|
14
|
+
spec.homepage = 'http://rubygems.org/gems/ggsm'
|
|
15
|
+
spec.license = 'MIT'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
23
|
+
spec.require_paths = ['lib']
|
|
24
|
+
|
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
27
|
+
|
|
28
|
+
spec.add_dependency 'thor'
|
|
29
|
+
spec.add_dependency 'colorize'
|
|
30
|
+
end
|
data/lib/ggsm.rb
CHANGED
|
@@ -1,29 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
require 'thor'
|
|
2
|
+
require_relative 'ggsm/version'
|
|
3
|
+
require_relative 'ggsm/flow/start'
|
|
4
|
+
require_relative 'ggsm/flow/update'
|
|
5
|
+
require_relative 'ggsm/flow/sync'
|
|
6
|
+
require_relative 'ggsm/flow/switch'
|
|
7
|
+
require_relative 'ggsm/flow/delete'
|
|
8
|
+
require_relative 'ggsm/flow/foreach'
|
|
3
9
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
module GGSM
|
|
11
|
+
class Cli < Thor
|
|
12
|
+
include Start
|
|
13
|
+
include Update
|
|
14
|
+
include Sync
|
|
15
|
+
include Switch
|
|
16
|
+
include Delete
|
|
17
|
+
include Foreach
|
|
7
18
|
|
|
19
|
+
desc 'start <branch> [<commit>] [<origin>]', 'Start to develop new feature'
|
|
20
|
+
def start(branch, action='')
|
|
21
|
+
start_flow(branch, action)
|
|
22
|
+
end
|
|
8
23
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
command = "git submodule foreach #{command};git add .;#{command}"
|
|
19
|
-
else
|
|
20
|
-
command = "git#{command};git submodule foreach git#{command}"
|
|
21
|
-
end
|
|
24
|
+
desc 'switch <branch>', 'Switch to branch <branch>'
|
|
25
|
+
def switch(branch)
|
|
26
|
+
switch_flow(branch)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
desc 'update', 'Update submodule'
|
|
30
|
+
def update
|
|
31
|
+
update_flow
|
|
32
|
+
end
|
|
22
33
|
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
desc 'sync', 'Sync remote app and submodules'
|
|
35
|
+
def sync
|
|
36
|
+
sync_flow
|
|
37
|
+
end
|
|
25
38
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
desc 'delete <branch> [-r|--remote] [-a|--all]', 'Delete <branch>'
|
|
40
|
+
option :remote, :default => false, :type => :boolean, aliases: '-r'
|
|
41
|
+
option :all, :default => false, :type => :boolean, aliases: '-a'
|
|
42
|
+
def delete(branch)
|
|
43
|
+
remote = options[:remote]
|
|
44
|
+
all = options[:all]
|
|
45
|
+
delete_flow(branch, remote, all)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
desc 'foreach [<commands>...]', 'Executes the git command in each module'
|
|
49
|
+
def foreach(*commands)
|
|
50
|
+
foreach_flow(*commands)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require_relative '../util/submodule'
|
|
2
|
+
require_relative '../util/stash'
|
|
3
|
+
|
|
4
|
+
module GGSM
|
|
5
|
+
module Delete
|
|
6
|
+
include Submodule
|
|
7
|
+
include Stash
|
|
8
|
+
|
|
9
|
+
def delete_flow(branch, remote, all)
|
|
10
|
+
unless check_submodule
|
|
11
|
+
return
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
puts '==> 进入主工程:'.yellow
|
|
15
|
+
|
|
16
|
+
delete_branch(all, branch, remote)
|
|
17
|
+
|
|
18
|
+
subs = get_submodule
|
|
19
|
+
subs.each do |sub|
|
|
20
|
+
Dir.chdir sub
|
|
21
|
+
puts "==> 进入#{sub}:".yellow
|
|
22
|
+
delete_branch(all, branch, remote)
|
|
23
|
+
Dir.chdir '..'
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def delete_branch(all, branch, remote)
|
|
28
|
+
if all
|
|
29
|
+
system "git branch -D #{branch}"
|
|
30
|
+
system "git push origin -d #{branch}"
|
|
31
|
+
elsif remote
|
|
32
|
+
system "git push origin -d #{branch}"
|
|
33
|
+
else
|
|
34
|
+
system "git branch -D #{branch}"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'colorize'
|
|
2
|
+
require_relative '../util/submodule'
|
|
3
|
+
require_relative '../util/stash'
|
|
4
|
+
|
|
5
|
+
module GGSM
|
|
6
|
+
module Foreach
|
|
7
|
+
include Submodule
|
|
8
|
+
include Stash
|
|
9
|
+
|
|
10
|
+
def foreach_flow(*commands)
|
|
11
|
+
unless check_submodule
|
|
12
|
+
return
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
cmd = ''
|
|
16
|
+
if commands.size == 0
|
|
17
|
+
puts '请输入正确git命令 foreach [<commands>...]'.red
|
|
18
|
+
return
|
|
19
|
+
elsif commands.fetch(0) == 'git'
|
|
20
|
+
commands.delete_at(0)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
commands.each do |arg|
|
|
24
|
+
cmd = "#{cmd} #{arg}"
|
|
25
|
+
end
|
|
26
|
+
puts cmd
|
|
27
|
+
|
|
28
|
+
subs = get_submodule
|
|
29
|
+
subs.each do |sub|
|
|
30
|
+
Dir.chdir sub
|
|
31
|
+
puts "==> *进入#{sub}:".yellow
|
|
32
|
+
system "git #{cmd}"
|
|
33
|
+
Dir.chdir '..'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
puts '==> *进入主工程:'.yellow
|
|
37
|
+
system "git #{cmd}"
|
|
38
|
+
|
|
39
|
+
puts "Modules执行:git#{cmd}".blue
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'colorize'
|
|
2
|
+
require_relative '../util/submodule'
|
|
3
|
+
require_relative '../util/stash'
|
|
4
|
+
|
|
5
|
+
module GGSM
|
|
6
|
+
module Start
|
|
7
|
+
include Submodule
|
|
8
|
+
include Stash
|
|
9
|
+
|
|
10
|
+
def start_flow(branch, action)
|
|
11
|
+
unless check_submodule
|
|
12
|
+
return
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
puts '==> 进入主工程:'.yellow
|
|
16
|
+
|
|
17
|
+
arry_conflict = []
|
|
18
|
+
|
|
19
|
+
need_stash = try_stash
|
|
20
|
+
result = system "git checkout -b #{branch} #{action}"
|
|
21
|
+
if need_stash
|
|
22
|
+
stash_pop(arry_conflict, '主工程')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
unless result
|
|
26
|
+
return
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
`git submodule update --init --recursive`
|
|
30
|
+
|
|
31
|
+
subs = get_submodule
|
|
32
|
+
subs.each do |sub|
|
|
33
|
+
Dir.chdir sub
|
|
34
|
+
puts "==> 进入#{sub}:".yellow
|
|
35
|
+
need_stash = try_stash
|
|
36
|
+
system "git checkout -b #{branch}"
|
|
37
|
+
if need_stash
|
|
38
|
+
stash_pop(arry_conflict, sub)
|
|
39
|
+
end
|
|
40
|
+
Dir.chdir '..'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
if arry_conflict.size > 0
|
|
44
|
+
tip = '==> 冲突待解决:'
|
|
45
|
+
arry_conflict.each do |sub|
|
|
46
|
+
tip = "#{tip} #{sub}"
|
|
47
|
+
end
|
|
48
|
+
puts tip.red
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'colorize'
|
|
2
|
+
require_relative '../util/submodule'
|
|
3
|
+
require_relative '../util/stash'
|
|
4
|
+
|
|
5
|
+
module GGSM
|
|
6
|
+
module Switch
|
|
7
|
+
include Submodule
|
|
8
|
+
include Stash
|
|
9
|
+
|
|
10
|
+
def switch_flow(branch)
|
|
11
|
+
unless check_submodule
|
|
12
|
+
return
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
puts '==> 进入主工程:'.yellow
|
|
16
|
+
|
|
17
|
+
arry_conflict = []
|
|
18
|
+
|
|
19
|
+
need_stash = try_stash
|
|
20
|
+
result = system "git checkout #{branch}"
|
|
21
|
+
if need_stash
|
|
22
|
+
stash_pop(arry_conflict, '主工程')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
unless result
|
|
26
|
+
return
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
sub_commits = get_submodule_commit
|
|
30
|
+
|
|
31
|
+
subs = get_submodule
|
|
32
|
+
subs.each do |sub|
|
|
33
|
+
Dir.chdir sub
|
|
34
|
+
puts "==> 进入#{sub}:".yellow
|
|
35
|
+
need_stash = try_stash
|
|
36
|
+
result = system "git checkout #{branch}"
|
|
37
|
+
|
|
38
|
+
if result
|
|
39
|
+
system "git reset --hard #{sub_commits.fetch(subs.index(sub))}"
|
|
40
|
+
else
|
|
41
|
+
puts "[#{sub}] 没有#{branch}分支,创建并切换到#{branch}".blue
|
|
42
|
+
system "git checkout -b #{branch}"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
if need_stash
|
|
46
|
+
stash_pop(arry_conflict, sub)
|
|
47
|
+
end
|
|
48
|
+
Dir.chdir '..'
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
if arry_conflict.size > 0
|
|
52
|
+
tip = '==> 冲突待解决:'
|
|
53
|
+
arry_conflict.each do |sub|
|
|
54
|
+
tip = "#{tip} #{sub}"
|
|
55
|
+
end
|
|
56
|
+
puts tip.red
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'colorize'
|
|
2
|
+
require_relative 'switch'
|
|
3
|
+
|
|
4
|
+
module GGSM
|
|
5
|
+
module Sync
|
|
6
|
+
include Switch
|
|
7
|
+
|
|
8
|
+
def sync_flow
|
|
9
|
+
unless check_submodule
|
|
10
|
+
return
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
result = system 'git pull'
|
|
14
|
+
unless result
|
|
15
|
+
return
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
current_branch = `git branch | grep "*"`.split("* ")[1].split("\n")[0]
|
|
19
|
+
switch_flow(current_branch)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module GGSM
|
|
2
|
+
module Stash
|
|
3
|
+
def try_stash
|
|
4
|
+
status = `git status | 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,37 @@
|
|
|
1
|
+
module GGSM
|
|
2
|
+
module Submodule
|
|
3
|
+
def check_submodule
|
|
4
|
+
sub_str = `git submodule`
|
|
5
|
+
if sub_str.empty?
|
|
6
|
+
puts '所在目录工程下不存在Submodule,请检查所在目录!'.red
|
|
7
|
+
return false
|
|
8
|
+
end
|
|
9
|
+
return true
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def get_submodule
|
|
13
|
+
sub_status = `git submodule`
|
|
14
|
+
pattern = /(?<=\s)[0-9a-zA-Z]*(?=\s)/
|
|
15
|
+
sub_status = sub_status.split(/\n/)
|
|
16
|
+
|
|
17
|
+
result = []
|
|
18
|
+
sub_status.each do |sub|
|
|
19
|
+
match = pattern.match(sub.strip)
|
|
20
|
+
result.push(match[0])
|
|
21
|
+
end
|
|
22
|
+
return result
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def get_submodule_commit
|
|
26
|
+
sub_commits = `git ls-tree HEAD | grep "160000"`
|
|
27
|
+
pattern = /(?<=\s)[0-9a-zA-Z]{40}(?=\s)/
|
|
28
|
+
sub_commits = sub_commits.split(/\n/)
|
|
29
|
+
result = []
|
|
30
|
+
sub_commits.each do |sub|
|
|
31
|
+
match = pattern.match(sub.strip)
|
|
32
|
+
result.push(match[0][0...7])
|
|
33
|
+
end
|
|
34
|
+
return result
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/ggsm/version.rb
ADDED
metadata
CHANGED
|
@@ -1,25 +1,99 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ggsm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- YoKey
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-05-
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
date: 2017-05-31 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.14'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ~>
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.14'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ~>
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ~>
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: thor
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - '>='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - '>='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: colorize
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - '>='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - '>='
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
description: A gem for Git Submodule
|
|
70
|
+
email:
|
|
71
|
+
- 328903522@qq.com
|
|
72
|
+
executables:
|
|
73
|
+
- ggsm
|
|
16
74
|
extensions: []
|
|
17
75
|
extra_rdoc_files: []
|
|
18
76
|
files:
|
|
77
|
+
- .gitignore
|
|
78
|
+
- .rspec
|
|
79
|
+
- .travis.yml
|
|
80
|
+
- CODE_OF_CONDUCT.md
|
|
81
|
+
- Gemfile
|
|
82
|
+
- LICENSE.txt
|
|
83
|
+
- README.md
|
|
19
84
|
- Rakefile
|
|
20
|
-
- lib/ggsm.rb
|
|
21
85
|
- bin/ggsm
|
|
22
|
-
-
|
|
86
|
+
- ggsm.gemspec
|
|
87
|
+
- lib/ggsm.rb
|
|
88
|
+
- lib/ggsm/flow/delete.rb
|
|
89
|
+
- lib/ggsm/flow/foreach.rb
|
|
90
|
+
- lib/ggsm/flow/start.rb
|
|
91
|
+
- lib/ggsm/flow/switch.rb
|
|
92
|
+
- lib/ggsm/flow/sync.rb
|
|
93
|
+
- lib/ggsm/flow/update.rb
|
|
94
|
+
- lib/ggsm/util/stash.rb
|
|
95
|
+
- lib/ggsm/util/submodule.rb
|
|
96
|
+
- lib/ggsm/version.rb
|
|
23
97
|
homepage: http://rubygems.org/gems/ggsm
|
|
24
98
|
licenses:
|
|
25
99
|
- MIT
|
|
@@ -40,9 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
40
114
|
version: '0'
|
|
41
115
|
requirements: []
|
|
42
116
|
rubyforge_project:
|
|
43
|
-
rubygems_version: 2.
|
|
117
|
+
rubygems_version: 2.6.12
|
|
44
118
|
signing_key:
|
|
45
|
-
specification_version:
|
|
46
|
-
summary: ggsm
|
|
47
|
-
test_files:
|
|
48
|
-
- test/test_ggsm.rb
|
|
119
|
+
specification_version: 4
|
|
120
|
+
summary: ggsm
|
|
121
|
+
test_files: []
|