gb 0.1.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 +13 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gb.yml +12 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +94 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/gb +7 -0
- data/exe/glb +7 -0
- data/gb.gemspec +39 -0
- data/lib/Command.rb +75 -0
- data/lib/commands/create.rb +67 -0
- data/lib/commands/create_tag.rb +104 -0
- data/lib/commands/delete_tag.rb +98 -0
- data/lib/commands/forall.rb +53 -0
- data/lib/commands/init.rb +36 -0
- data/lib/commands/merge.rb +249 -0
- data/lib/commands/review.rb +260 -0
- data/lib/commands/start.rb +116 -0
- data/lib/commands/status.rb +78 -0
- data/lib/commands/sync.rb +45 -0
- data/lib/commands/workspace.rb +38 -0
- data/lib/config/gb_config.rb +73 -0
- data/lib/config/work_space_config.rb +25 -0
- data/lib/ext/git_ext.rb +120 -0
- data/lib/ext/gitlab_ext.rb +26 -0
- data/lib/gb.rb +8 -0
- data/lib/gb/version.rb +3 -0
- data/lib/sub_command.rb +139 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7906c461cd27972045e125ef182976ef576a779d38779df2977d1db98c512ae2
|
4
|
+
data.tar.gz: f62642d10be7fb980816de0d755efc133d9c45d24567127e9df9d5a35c15cdd8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 94461a92b513498eaf6c2ba20c219645ada7528066057ca4ad57c55e3c65d400fb5be6c491384a3adf18466b2437e2c73eaeda3e32986c2c50a8c339dabc4333
|
7
|
+
data.tar.gz: c0aabb519e76d5de400bf366b8a9170bc5cf4e0fc8d3a9837965e79fb62a7ad0d28d3b03e40aa3cc6d8e4c753ded1e15a13309b1cb6fb8779309c1be32c626c5
|
data/.gitignore
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 luobin02@baijiahulian.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/Gb.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
projects:
|
2
|
+
|
3
|
+
- name: TODO
|
4
|
+
## git: http://{username}:{password}@git.tianxiao100.com/tianxiao-ios/tianxiao/tianxiao-base-iphone-sdk.git
|
5
|
+
git: TODO
|
6
|
+
|
7
|
+
gitlab:
|
8
|
+
# GitLab api url. example http://git.tianxiao100.com/api/v4
|
9
|
+
endpoint: http://git.tianxiao100.com/api/v4
|
10
|
+
# set a your private token
|
11
|
+
# user's private token or OAuth2 access token
|
12
|
+
private_token: TODO
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 binluo
|
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,94 @@
|
|
1
|
+
# Gb
|
2
|
+
GB是针对GitLab开发的一款管理工具,使用ruby开发,简化对多个git版本库的管理,方便代码同步及代码提交review。
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'gb'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install gb
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
### 1、创建gb配置文件Gb.yml
|
23
|
+
```ruby
|
24
|
+
#创建本地文件Gb.yml,根据提示输入Gitlab的private token
|
25
|
+
gb create
|
26
|
+
#或通过在线url地址下载Gb.yml
|
27
|
+
gb create --config_url=[url]
|
28
|
+
```
|
29
|
+
|
30
|
+
### 2、gb初始化,下载代码
|
31
|
+
```ruby
|
32
|
+
gb init
|
33
|
+
```
|
34
|
+
|
35
|
+
### 3、开启gb工作区
|
36
|
+
开启gb工作区,指定本地工作分支名称和远程跟踪分支\
|
37
|
+
--force选项可以忽略工作分支存在校验
|
38
|
+
```ruby
|
39
|
+
gb start dev-v3.10.0 dev
|
40
|
+
```
|
41
|
+
|
42
|
+
### 4、同步工作区代码
|
43
|
+
开启工作区以后,通过
|
44
|
+
```ruby
|
45
|
+
gb sync
|
46
|
+
```
|
47
|
+
可以把远程分支代码同步到本地工作区,实现代码更新
|
48
|
+
|
49
|
+
### 4、提交review
|
50
|
+
当您本地git提交代码到本地工作分支,需要提交merge request时,通过命令
|
51
|
+
```ruby
|
52
|
+
gb review
|
53
|
+
```
|
54
|
+
自动同步本地工作分支代码到远程,并提交merge request
|
55
|
+
|
56
|
+
### 5、其他命令
|
57
|
+
```ruby
|
58
|
+
#查看本地工作区信息
|
59
|
+
gb workspace
|
60
|
+
|
61
|
+
#查看本地代码提交情况,类似git status
|
62
|
+
gb status
|
63
|
+
|
64
|
+
#提交merge request,可以自由指定发起merge的分支,并且不会同步本地代码
|
65
|
+
gb merge dev master
|
66
|
+
|
67
|
+
#遍历工作执行命令
|
68
|
+
gb forall --c="git pull"
|
69
|
+
|
70
|
+
#创建远程tag
|
71
|
+
gb create-tag master release_v3.9.1
|
72
|
+
|
73
|
+
#删除远程tag
|
74
|
+
gb delete-tag release_v3.9.1
|
75
|
+
|
76
|
+
```
|
77
|
+
|
78
|
+
## Development
|
79
|
+
|
80
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
81
|
+
|
82
|
+
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).
|
83
|
+
|
84
|
+
## Contributing
|
85
|
+
|
86
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/luobin23628/gb. 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.
|
87
|
+
|
88
|
+
## License
|
89
|
+
|
90
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
91
|
+
|
92
|
+
## Code of Conduct
|
93
|
+
|
94
|
+
Everyone interacting in the Gb project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/gb/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gb"
|
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/exe/gb
ADDED
data/exe/glb
ADDED
data/gb.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "gb/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "gb"
|
7
|
+
spec.version = Gb::VERSION
|
8
|
+
spec.authors = ["binluo"]
|
9
|
+
spec.email = ["luobin23628@163.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{gitlab工具}
|
12
|
+
spec.description = %q{方便处理多个gitlab仓库}
|
13
|
+
spec.homepage = "https://github.com/luobin23628/gb"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
20
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_dependency "gitlab", "~> 4.12.0"
|
32
|
+
spec.add_dependency "claide", "~> 1.0.2"
|
33
|
+
spec.add_dependency "colored2", "~>3.1.2 "
|
34
|
+
spec.add_dependency "git", "~>1.5.0 "
|
35
|
+
|
36
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
37
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
38
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
39
|
+
end
|
data/lib/Command.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'claide'
|
2
|
+
require 'config/work_space_config'
|
3
|
+
require 'gb'
|
4
|
+
|
5
|
+
module Gb
|
6
|
+
class Error < StandardError; end
|
7
|
+
|
8
|
+
class Command < CLAide::Command
|
9
|
+
|
10
|
+
require 'commands/init'
|
11
|
+
require 'commands/sync'
|
12
|
+
require 'commands/start'
|
13
|
+
require 'commands/review'
|
14
|
+
require 'commands/create_tag'
|
15
|
+
require 'commands/delete_tag'
|
16
|
+
require 'commands/create'
|
17
|
+
require 'commands/status'
|
18
|
+
require 'commands/forall'
|
19
|
+
require 'commands/merge'
|
20
|
+
require 'commands/workspace'
|
21
|
+
|
22
|
+
self.abstract_command = true
|
23
|
+
self.command = 'gb'
|
24
|
+
self.version = VERSION
|
25
|
+
self.description = 'gb, the gitlab helper.'
|
26
|
+
|
27
|
+
def self.run(argv)
|
28
|
+
help! 'You cannot run gb as root.' if Process.uid == 0 && !Gem.win_platform?
|
29
|
+
super(argv)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.handle_exception(command, exception)
|
33
|
+
if exception.is_a?(Error) || exception.is_a?(Git::GitExecuteError)
|
34
|
+
puts exception.message.red
|
35
|
+
if command.nil? || command.verbose?
|
36
|
+
puts
|
37
|
+
puts(*exception.backtrace)
|
38
|
+
end
|
39
|
+
exit(1)
|
40
|
+
elsif exception.is_a?(Gitlab::Error::ResponseError)
|
41
|
+
if command.nil? || command.verbose?
|
42
|
+
puts(exception.message.red)
|
43
|
+
puts(*exception.backtrace)
|
44
|
+
else
|
45
|
+
puts exception.message.red
|
46
|
+
end
|
47
|
+
exit(1)
|
48
|
+
else
|
49
|
+
super
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.report_error(exception)
|
54
|
+
case exception
|
55
|
+
when Interrupt
|
56
|
+
puts '[!] Cancelled'.red
|
57
|
+
exit(1)
|
58
|
+
when SystemExit
|
59
|
+
raise
|
60
|
+
else
|
61
|
+
raise exception
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def info(message)
|
66
|
+
puts(message.green)
|
67
|
+
end
|
68
|
+
|
69
|
+
def error(message)
|
70
|
+
puts(message.red)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'sub_command'
|
2
|
+
require "open-uri"
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
module Gb
|
6
|
+
class Create < SubCommand
|
7
|
+
|
8
|
+
self.summary = '创建并配置Gb.yml.'
|
9
|
+
|
10
|
+
self.description = <<-DESC
|
11
|
+
创建并配置Gb.yml.
|
12
|
+
DESC
|
13
|
+
|
14
|
+
def self.options
|
15
|
+
options = [
|
16
|
+
["--config_url=[url]", "指定配置文件url地址"],
|
17
|
+
].concat(super)
|
18
|
+
options.delete_if do |option|
|
19
|
+
option[0] =~ /^--config=/
|
20
|
+
end
|
21
|
+
options
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(argv)
|
25
|
+
@config_url = argv.option('config_url')
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate!
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def run
|
34
|
+
local_config_path = "./Gb.yml"
|
35
|
+
if File.exist?(local_config_path)
|
36
|
+
raise Error.new("'#{local_config_path}' exists.")
|
37
|
+
end
|
38
|
+
|
39
|
+
if @config_url.nil?
|
40
|
+
path = File.expand_path("../../Gb.yml", File.dirname(__FILE__))
|
41
|
+
if File.exist?(path)
|
42
|
+
gb_config = GbConfig.load_file(path)
|
43
|
+
else
|
44
|
+
raise Error.new("'#{path}' not found.")
|
45
|
+
end
|
46
|
+
else
|
47
|
+
yml_response = nil
|
48
|
+
open(@config_url) do |http|
|
49
|
+
yml_response = http.read
|
50
|
+
end
|
51
|
+
gb_config = GbConfig.load_yml(yml_response)
|
52
|
+
end
|
53
|
+
|
54
|
+
begin
|
55
|
+
print "Input GitLab private token: "
|
56
|
+
private_token = STDIN.gets.chomp
|
57
|
+
end until private_token.length > 0
|
58
|
+
|
59
|
+
gb_config.gitlab.private_token = private_token
|
60
|
+
|
61
|
+
File.open("./Gb.yml", 'w') do |file|
|
62
|
+
Psych.dump(gb_config.to_dictionary, file)
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|