deodorant 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +51 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +65 -0
- data/LICENSE.txt +21 -0
- data/README.md +33 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/deodorant.gemspec +32 -0
- data/exe/deodorant +77 -0
- data/lib/deodorant/comment.rb +5 -0
- data/lib/deodorant/config.rb +17 -0
- data/lib/deodorant/gerrit.rb +32 -0
- data/lib/deodorant/github.rb +58 -0
- data/lib/deodorant/repo.rb +55 -0
- data/lib/deodorant/version.rb +3 -0
- data/lib/deodorant.rb +5 -0
- metadata +215 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 87cebce20fdb3de06bf7abe7e8e71c622b20ef0b
|
4
|
+
data.tar.gz: d57fdf9376dfd5cad2594a1fbae8c462c603e5db
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2b621b53b36a4eb4f17a76375d3ffe6ca04137d5de011d830039d2b460eace82ba0f75533925bb3b54965e72c46e3f131554f4c13cf7a15ab3f4611d67e1b814
|
7
|
+
data.tar.gz: 564643ae5a76e9e15b5db0328e0234ce89735796918dbb5398b1503c05fb8adc2b704e2e0b4b37b2dea3d2b747d70f09e0abcaa0134fb130ac48f7ad1512cd52
|
data/.gitignore
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
.rspec_status
|
38
|
+
|
39
|
+
## Environment normalization:
|
40
|
+
/.bundle/
|
41
|
+
/vendor/bundle
|
42
|
+
/lib/bundler/man/
|
43
|
+
|
44
|
+
# for a library or gem, you might want to ignore these files since the code is
|
45
|
+
# intended to run in multiple environments; otherwise, check them in:
|
46
|
+
# Gemfile.lock
|
47
|
+
.ruby-version
|
48
|
+
.ruby-gemset
|
49
|
+
|
50
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
51
|
+
.rvmrc
|
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 nathanm@instructure.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/Gemfile.lock
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
deodorant (0.1.0)
|
5
|
+
cocaine (~> 0.5.8)
|
6
|
+
gerry (~> 0.1)
|
7
|
+
git (~> 1.3)
|
8
|
+
highline (~> 1.7, >= 1.7.8)
|
9
|
+
octokit (~> 4.2)
|
10
|
+
rainbow (~> 2.2, >= 2.2.1)
|
11
|
+
thor (~> 0.19.1)
|
12
|
+
|
13
|
+
GEM
|
14
|
+
remote: https://rubygems.org/
|
15
|
+
specs:
|
16
|
+
addressable (2.5.1)
|
17
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
18
|
+
climate_control (0.1.0)
|
19
|
+
cocaine (0.5.8)
|
20
|
+
climate_control (>= 0.0.3, < 1.0)
|
21
|
+
diff-lcs (1.3)
|
22
|
+
faraday (0.12.0.1)
|
23
|
+
multipart-post (>= 1.2, < 3)
|
24
|
+
gerry (0.1.2)
|
25
|
+
httparty
|
26
|
+
git (1.3.0)
|
27
|
+
highline (1.7.8)
|
28
|
+
httparty (0.14.0)
|
29
|
+
multi_xml (>= 0.5.2)
|
30
|
+
multi_xml (0.6.0)
|
31
|
+
multipart-post (2.0.0)
|
32
|
+
octokit (4.7.0)
|
33
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
34
|
+
public_suffix (2.0.5)
|
35
|
+
rainbow (2.2.1)
|
36
|
+
rake (10.5.0)
|
37
|
+
rspec (3.5.0)
|
38
|
+
rspec-core (~> 3.5.0)
|
39
|
+
rspec-expectations (~> 3.5.0)
|
40
|
+
rspec-mocks (~> 3.5.0)
|
41
|
+
rspec-core (3.5.4)
|
42
|
+
rspec-support (~> 3.5.0)
|
43
|
+
rspec-expectations (3.5.0)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.5.0)
|
46
|
+
rspec-mocks (3.5.0)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.5.0)
|
49
|
+
rspec-support (3.5.0)
|
50
|
+
sawyer (0.8.1)
|
51
|
+
addressable (>= 2.3.5, < 2.6)
|
52
|
+
faraday (~> 0.8, < 1.0)
|
53
|
+
thor (0.19.4)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
bundler (~> 1.14)
|
60
|
+
deodorant!
|
61
|
+
rake (~> 10.0)
|
62
|
+
rspec (~> 3.0)
|
63
|
+
|
64
|
+
BUNDLED WITH
|
65
|
+
1.14.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Nathan Mills
|
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,33 @@
|
|
1
|
+
# Deodorant
|
2
|
+
|
3
|
+
Deodorant is a gem to allow you to use github as an interface for gerrit
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem install 'deodorant'
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
To setup a repo, run the following in the repo directory:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
deodorant init
|
17
|
+
```
|
18
|
+
|
19
|
+
## Development
|
20
|
+
|
21
|
+
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.
|
22
|
+
|
23
|
+
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).
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/deodorant. 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.
|
28
|
+
|
29
|
+
|
30
|
+
## License
|
31
|
+
|
32
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
33
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "deodorant"
|
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/deodorant.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'deodorant/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "deodorant"
|
8
|
+
spec.version = Deodorant::VERSION
|
9
|
+
spec.authors = ["Nathan Mills"]
|
10
|
+
spec.email = ["rivernate@gmail.com"]
|
11
|
+
spec.summary = %q{A CLI tool to inegrate github with gerrit}
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
15
|
+
f.match(%r{^(test|spec|features)/})
|
16
|
+
end
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'cocaine', '~> 0.5.8'
|
22
|
+
spec.add_dependency 'gerry', '~> 0.1'
|
23
|
+
spec.add_dependency 'git', '~> 1.3'
|
24
|
+
spec.add_dependency 'highline','~> 1.7', '>= 1.7.8'
|
25
|
+
spec.add_dependency 'octokit', '~> 4.2'
|
26
|
+
spec.add_dependency 'rainbow', '~> 2.2', '>= 2.2.1'
|
27
|
+
spec.add_dependency 'thor', '~> 0.19.1'
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
end
|
data/exe/deodorant
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'deodorant'
|
4
|
+
require 'rainbow'
|
5
|
+
require 'thor'
|
6
|
+
|
7
|
+
class DeodorantExec < Thor
|
8
|
+
|
9
|
+
desc 'init', 'initialize repo to use github and gerrit'
|
10
|
+
long_desc <<-LONGDESC
|
11
|
+
`deodorant init` will initialize the repo using github for push by default, and gerrit for pull.
|
12
|
+
deodorant will use the remotes "github", and "gerrit" if you already have them configured, or you
|
13
|
+
can specify using the optional options:
|
14
|
+
|
15
|
+
[--github_url | -g]
|
16
|
+
[--gerrit_url | -G]
|
17
|
+
|
18
|
+
the github_repo_url is required, if the gerrit_repo_url is not provided origin will
|
19
|
+
be assumed to be gerrit
|
20
|
+
> $ deodorant init ssh://git@github.com/rivernate/deodorant ssh://user@gerrit.example.com/deodorant
|
21
|
+
LONGDESC
|
22
|
+
option :github_url, type: :string, aliases: 'g'
|
23
|
+
option :gerrit_url, type: :string, aliases: 'G'
|
24
|
+
|
25
|
+
def init
|
26
|
+
repo = Deodorant::Repo.new(github_url: options[:github_url], gerrit_url: options[:gerrit_url])
|
27
|
+
repo.setup
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'pull_requests', 'list the pull requests for this repo', hidden: true
|
31
|
+
|
32
|
+
def pull_requests
|
33
|
+
gh = Deodorant::Github.new
|
34
|
+
prs = gh.pull_requests(state: (options[:state] || 'open'))
|
35
|
+
prs.sort {|x, y| x.number <=> y.number}.each do |pr|
|
36
|
+
number = Rainbow(pr.number).white
|
37
|
+
title = Rainbow(pr.title).green
|
38
|
+
printf('%s: %s', number, title)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'pull-requests', 'list the pull requests for this repo', for: 'pull_requests'
|
43
|
+
long_desc <<-LONGDESC
|
44
|
+
'deodorant pull-requests' will list all of the open pull requests by default
|
45
|
+
you can change what pull requests it display by using the [--state | -s] option
|
46
|
+
> $ deodorant pull-requests
|
47
|
+
LONGDESC
|
48
|
+
option :state, type: :string, aliases: 's'
|
49
|
+
|
50
|
+
desc 'pr2gr PR_NUMBER', 'push a github pull request to gerrit'
|
51
|
+
long_desc <<-LONGDESC
|
52
|
+
'deodorant pr2gr' will fetch the head of the provided pull request, and squish it
|
53
|
+
down to the base commit of the pull request. Then push up the squashed commit with
|
54
|
+
the pull request title and description as the commit message
|
55
|
+
> $ deodorant pr2gr 1
|
56
|
+
LONGDESC
|
57
|
+
def pr2gr(pr_number)
|
58
|
+
repo = Deodorant::Repo.new
|
59
|
+
repo.pr_to_gerrit(pr_number: pr_number)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def rainbow
|
65
|
+
@rainbow ||= Rainbow.new
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
if !ARGV.empty? && %w[-v --version].include?(ARGV.first)
|
71
|
+
puts "Deodorant - Version: #{Deodorant::VERSION}"
|
72
|
+
else
|
73
|
+
DeodorantExec.start
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'gerry'
|
2
|
+
|
3
|
+
module Deodorant
|
4
|
+
class Gerrit
|
5
|
+
|
6
|
+
def initialize(gerry: nil, git_client: nil)
|
7
|
+
@git_client = git_client || Repo.default_git_client
|
8
|
+
@gerry = gerry || Gerry.new(
|
9
|
+
URI.parse(@git_client.remote('gerrit').url).host,
|
10
|
+
Config.gerrit_username,
|
11
|
+
Config.gerrit_password
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
# def push_comments(comms:)
|
16
|
+
# end
|
17
|
+
|
18
|
+
def squash_and_push(base_sha:, head_sha:, commit_message:)
|
19
|
+
@git_client.checkout head_sha
|
20
|
+
@git_client.reset base_sha
|
21
|
+
@git_client.add(all: true)
|
22
|
+
@git_client.commit(commit_message)
|
23
|
+
@git_client.push('gerrit', 'HEAD:refs/for/master')
|
24
|
+
parse_change_id(commit_message: @git_client.log.first.message)
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse_change_id(commit_message:)
|
28
|
+
change_id = %r{Change-Id: (\d*\w*)$}.match(commit_message).captures.first
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'octokit'
|
2
|
+
|
3
|
+
module Deodorant
|
4
|
+
class Github
|
5
|
+
|
6
|
+
OCTOKIT_CLIENT_NEW = Octokit::Client.new(access_token: Config.github_token)
|
7
|
+
|
8
|
+
def initialize(octokit: nil, git_client: nil)
|
9
|
+
@octokit = octokit || OCTOKIT_CLIENT_NEW
|
10
|
+
@git_client = git_client || Repo.default_git_client
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def update_github
|
15
|
+
@git_client.fetch('gerrit')
|
16
|
+
@git_client.push('github', 'gerrit/master:refs/heads/master')
|
17
|
+
end
|
18
|
+
|
19
|
+
def pull_requests(state: 'open')
|
20
|
+
@octokit.pull_requests(github_repo, state: state)
|
21
|
+
end
|
22
|
+
|
23
|
+
def pull_request(number:)
|
24
|
+
@octokit.pull_request(github_repo, number)
|
25
|
+
end
|
26
|
+
|
27
|
+
def comments(pr_number:)
|
28
|
+
review_comments = pull_request(pr_number).rels[:review_comments].get.data
|
29
|
+
comms = review_comments.map do |c|
|
30
|
+
com = Comment.new
|
31
|
+
com.github_id = c.id
|
32
|
+
com.path = c.path
|
33
|
+
com.line = c.position
|
34
|
+
com.message = c.body
|
35
|
+
com.author = c.user.login
|
36
|
+
end
|
37
|
+
comms
|
38
|
+
end
|
39
|
+
|
40
|
+
def append_change_id_to_pr(pr_number:, change_id:)
|
41
|
+
pr = pull_request(number: pr_number)
|
42
|
+
unless pr.body.include?(change_id)
|
43
|
+
new_body = pr.body << "\n\nChange-Id: #{change_id}"
|
44
|
+
@octokit.update_pull_request(github_repo, pr_number, body: new_body)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def github_repo
|
51
|
+
@github_rebo ||= begin
|
52
|
+
url = @git_client.remote('github').url
|
53
|
+
URI.parse(url).path.gsub(%r{^\/}, '')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'git'
|
2
|
+
|
3
|
+
module Deodorant
|
4
|
+
class Repo
|
5
|
+
|
6
|
+
def self.default_git_client
|
7
|
+
Git.open(Dir.pwd)
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(github_url: nil, gerrit_url: nil, git_client: nil)
|
11
|
+
@git_client = git_client || Repo.default_git_client
|
12
|
+
@github_url = github_url || @git_client.remote('github').url
|
13
|
+
@gerrit_url = gerrit_url || @git_client.remote('gerrit').url
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
remotes = @git_client.remotes.map(&:name)
|
18
|
+
%w[hybrid gerrit github].each {|r| send("add_#{r}_remote") unless remotes.include?(r)}
|
19
|
+
@git_client.config('branch.master.remote', 'hybrid')
|
20
|
+
end
|
21
|
+
|
22
|
+
def pr_to_gerrit(pr_number:)
|
23
|
+
current_branch = @git_client.current_branch
|
24
|
+
begin
|
25
|
+
github = Github.new
|
26
|
+
pr = github.pull_request(number: pr_number)
|
27
|
+
pr_title = pr[:title]
|
28
|
+
pr_body = pr[:body]
|
29
|
+
head_sha = pr[:head][:sha]
|
30
|
+
base_sha = pr[:base][:sha]
|
31
|
+
gerrit = Gerrit.new
|
32
|
+
change_id = gerrit.squash_and_push(base_sha: base_sha, head_sha: head_sha, commit_message: "#{pr_title}\n\n#{pr_body}")
|
33
|
+
github.append_change_id_to_pr(pr_number: pr_number, change_id: change_id)
|
34
|
+
ensure
|
35
|
+
@git_client.checkout current_branch
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def add_hybrid_remote
|
42
|
+
@git_client.add_remote('hybrid', @gerrit_url)
|
43
|
+
@git_client.config('remote.hybrid.pushurl', @github_url)
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_github_remote
|
47
|
+
@git_client.add_remote('github', @github_url)
|
48
|
+
end
|
49
|
+
|
50
|
+
def add_gerrit_remote
|
51
|
+
@git_client.add_remote('gerrit', @gerrit_url)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
data/lib/deodorant.rb
ADDED
metadata
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deodorant
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nathan Mills
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cocaine
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.5.8
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.5.8
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gerry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.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.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: git
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: highline
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.7'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 1.7.8
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '1.7'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 1.7.8
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: octokit
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '4.2'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '4.2'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rainbow
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '2.2'
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 2.2.1
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '2.2'
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 2.2.1
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: thor
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 0.19.1
|
116
|
+
type: :runtime
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 0.19.1
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: bundler
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '1.14'
|
130
|
+
type: :development
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '1.14'
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: rake
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - "~>"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '10.0'
|
144
|
+
type: :development
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - "~>"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '10.0'
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
name: rspec
|
153
|
+
requirement: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '3.0'
|
158
|
+
type: :development
|
159
|
+
prerelease: false
|
160
|
+
version_requirements: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - "~>"
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '3.0'
|
165
|
+
description:
|
166
|
+
email:
|
167
|
+
- rivernate@gmail.com
|
168
|
+
executables:
|
169
|
+
- deodorant
|
170
|
+
extensions: []
|
171
|
+
extra_rdoc_files: []
|
172
|
+
files:
|
173
|
+
- ".gitignore"
|
174
|
+
- CODE_OF_CONDUCT.md
|
175
|
+
- Gemfile
|
176
|
+
- Gemfile.lock
|
177
|
+
- LICENSE.txt
|
178
|
+
- README.md
|
179
|
+
- Rakefile
|
180
|
+
- bin/console
|
181
|
+
- bin/setup
|
182
|
+
- deodorant.gemspec
|
183
|
+
- exe/deodorant
|
184
|
+
- lib/deodorant.rb
|
185
|
+
- lib/deodorant/comment.rb
|
186
|
+
- lib/deodorant/config.rb
|
187
|
+
- lib/deodorant/gerrit.rb
|
188
|
+
- lib/deodorant/github.rb
|
189
|
+
- lib/deodorant/repo.rb
|
190
|
+
- lib/deodorant/version.rb
|
191
|
+
homepage:
|
192
|
+
licenses:
|
193
|
+
- MIT
|
194
|
+
metadata: {}
|
195
|
+
post_install_message:
|
196
|
+
rdoc_options: []
|
197
|
+
require_paths:
|
198
|
+
- lib
|
199
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
200
|
+
requirements:
|
201
|
+
- - ">="
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: '0'
|
204
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
requirements: []
|
210
|
+
rubyforge_project:
|
211
|
+
rubygems_version: 2.6.11
|
212
|
+
signing_key:
|
213
|
+
specification_version: 4
|
214
|
+
summary: A CLI tool to inegrate github with gerrit
|
215
|
+
test_files: []
|