octo-merge 0.7.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +8 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +129 -0
- data/Rakefile +6 -0
- data/TODO.md +11 -0
- data/bin/console +14 -0
- data/bin/octo-merge +9 -0
- data/bin/setup +8 -0
- data/exe/octo-merge +8 -0
- data/lib/git.rb +61 -0
- data/lib/octo_merge.rb +44 -0
- data/lib/octo_merge/cli.rb +53 -0
- data/lib/octo_merge/cli/parser.rb +102 -0
- data/lib/octo_merge/configuration.rb +5 -0
- data/lib/octo_merge/context.rb +21 -0
- data/lib/octo_merge/execute.rb +21 -0
- data/lib/octo_merge/interactive_pull_requests.rb +47 -0
- data/lib/octo_merge/list_pull_requests.rb +20 -0
- data/lib/octo_merge/options.rb +108 -0
- data/lib/octo_merge/pull_request.rb +54 -0
- data/lib/octo_merge/setup.rb +74 -0
- data/lib/octo_merge/strategy.rb +11 -0
- data/lib/octo_merge/strategy/base.rb +53 -0
- data/lib/octo_merge/strategy/merge_with_rebase.rb +29 -0
- data/lib/octo_merge/strategy/merge_with_rebase_and_message.rb +90 -0
- data/lib/octo_merge/strategy/merge_without_rebase.rb +24 -0
- data/lib/octo_merge/strategy/rebase.rb +21 -0
- data/lib/octo_merge/version.rb +3 -0
- data/octo_merge.gemspec +34 -0
- metadata +205 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 878087419505c2889d26336412ef9d8baa52b294
|
4
|
+
data.tar.gz: 1d398a00add5efd12d194f84a4d740e6ba5fefe4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 88da4079d3c790e0395afd2f2fd95e6cdf3faf98c22be3df15f6728e71d8a80e9144787d0b89da3efeebe8f8ea64054b142e05ab81339f24b82985d96de8e10b
|
7
|
+
data.tar.gz: 482e8e48ccd3a599a7c8848f243c6b0952428d6981b7934f9c02f5bf26467aa3759be2aee76a2f67522b4570bbbc2bd9ca5771428ee875f76967d4fc2376ab9f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at me@patrick-helm.de. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Patrick Helm
|
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,129 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/Deradon/octo-merge.svg?branch=master)](https://travis-ci.org/Deradon/octo-merge)
|
2
|
+
|
3
|
+
**WARNING**
|
4
|
+
|
5
|
+
This is still **WIP**. Using this tool will change your local master branch
|
6
|
+
and under certain circumstances some of your feature branches too!
|
7
|
+
|
8
|
+
Use at your own risk!
|
9
|
+
|
10
|
+
# OctoMerge
|
11
|
+
|
12
|
+
`octo-merge` is a simple command line tool to merge GitHub pull requests using different strategies.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'octo-merge'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install octo-merge
|
29
|
+
|
30
|
+
## Setup / Configure
|
31
|
+
|
32
|
+
If you do not want to provide your GitHub login credentials every time you
|
33
|
+
call `octo-merge` you can easily set these in your `~/.octo-merge.yml`.
|
34
|
+
|
35
|
+
Feel free to use the included setup task:
|
36
|
+
|
37
|
+
```
|
38
|
+
octo-merge --setup
|
39
|
+
```
|
40
|
+
|
41
|
+
## Examples
|
42
|
+
|
43
|
+
```
|
44
|
+
# Within your shell
|
45
|
+
|
46
|
+
octo-merge \
|
47
|
+
--repo=rails/rails \
|
48
|
+
--dir=~/Dev/Rails/rails \
|
49
|
+
--pull_requests=23,42 \
|
50
|
+
--login=Deradon \
|
51
|
+
--password=<your-github-API-token> \
|
52
|
+
--strategy=MergeWithRebase
|
53
|
+
```
|
54
|
+
|
55
|
+
* You can find your API token [here](https://github.com/settings/tokens)
|
56
|
+
|
57
|
+
## Available Strategies
|
58
|
+
|
59
|
+
* NOTE: All strategies are using read-only branches for a specific pull requests.
|
60
|
+
This way we avoid adding lot of remotes.
|
61
|
+
* Read more: [Checking out pull requests locally](https://help.github.com/articles/checking-out-pull-requests-locally/)
|
62
|
+
|
63
|
+
### MergeWithoutRebase
|
64
|
+
|
65
|
+
```
|
66
|
+
# Reset master
|
67
|
+
git checkout master
|
68
|
+
git fetch upstream
|
69
|
+
git reset --hard upstream/master
|
70
|
+
|
71
|
+
# For each pull request
|
72
|
+
git fetch upstream pull/23/head:pull/23 --force"
|
73
|
+
git merge --no-ff pull/23
|
74
|
+
git branch -D pull/23
|
75
|
+
```
|
76
|
+
|
77
|
+
### MergeWithRebase
|
78
|
+
|
79
|
+
```
|
80
|
+
# Reset master
|
81
|
+
git checkout master
|
82
|
+
git fetch upstream
|
83
|
+
git reset --hard upstream/master
|
84
|
+
|
85
|
+
# For each pull request
|
86
|
+
git fetch upstream pull/23/head:pull/23 --force"
|
87
|
+
git checkout pull/23
|
88
|
+
git rebase master
|
89
|
+
|
90
|
+
git checkout master
|
91
|
+
git merge --no-ff pull/23
|
92
|
+
|
93
|
+
git branch -D pull/23
|
94
|
+
```
|
95
|
+
|
96
|
+
### Rebase
|
97
|
+
|
98
|
+
```
|
99
|
+
# Reset master
|
100
|
+
git checkout master
|
101
|
+
git fetch upstream
|
102
|
+
git reset --hard upstream/master
|
103
|
+
|
104
|
+
# For each pull request
|
105
|
+
git fetch upstream pull/23/head:pull/23 --force"
|
106
|
+
git checkout pull/23
|
107
|
+
git rebase master
|
108
|
+
|
109
|
+
git checkout master
|
110
|
+
git rebase pull/23
|
111
|
+
|
112
|
+
git branch -D pull/23
|
113
|
+
```
|
114
|
+
|
115
|
+
## Development
|
116
|
+
|
117
|
+
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.
|
118
|
+
|
119
|
+
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).
|
120
|
+
|
121
|
+
## Contributing
|
122
|
+
|
123
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Deradon/octo-merge. 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.
|
124
|
+
|
125
|
+
|
126
|
+
## License
|
127
|
+
|
128
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
129
|
+
|
data/Rakefile
ADDED
data/TODO.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# TODO
|
2
|
+
|
3
|
+
Before we release `v1.0.0` the following tasks needs to be done:
|
4
|
+
|
5
|
+
* [x] Move logic from `exe/octo-merge` into a testable class
|
6
|
+
* [x] Add specs for `InteractivePullRequests`
|
7
|
+
* [x] Create a setup task
|
8
|
+
* [ ] Complete docs (`README.md`)
|
9
|
+
* [ ] Try to get rid of external dependencies (`octokit`, `inquirer`)
|
10
|
+
* [x] Decide on gem name (`octo_merge` VS `octo-merge`)
|
11
|
+
* [x] Use GitHubs `secret` pull requests branches instead of adding new remotes
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "octo_merge"
|
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
|
data/bin/octo-merge
ADDED
data/bin/setup
ADDED
data/exe/octo-merge
ADDED
data/lib/git.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
# TODO: Move to another repository (e.g.: `SimpleGit`)
|
4
|
+
class Git
|
5
|
+
def self.git(method_name, cmd = nil)
|
6
|
+
define_method(method_name) do |args|
|
7
|
+
if cmd
|
8
|
+
git("#{cmd} #{args}")
|
9
|
+
else
|
10
|
+
git("#{method_name} #{args}")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.verbose!(is_verbose = true)
|
16
|
+
@verbose = is_verbose
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.verbose?
|
20
|
+
!!@verbose
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :working_directory
|
24
|
+
|
25
|
+
def initialize(working_directory)
|
26
|
+
@working_directory ||= File.absolute_path(working_directory)
|
27
|
+
end
|
28
|
+
|
29
|
+
git :checkout
|
30
|
+
git :commit
|
31
|
+
git :delete_branch, "branch -D"
|
32
|
+
git :fetch
|
33
|
+
git :merge_no_ff, "merge --no-ff"
|
34
|
+
git :rebase
|
35
|
+
git :remote_add, "remote add"
|
36
|
+
git :reset_hard, "reset --hard"
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def git(cmd)
|
41
|
+
run "git #{cmd}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def verbose?
|
45
|
+
self.class.verbose?
|
46
|
+
end
|
47
|
+
|
48
|
+
def run(cmd)
|
49
|
+
puts "$: #{cmd}" if verbose?
|
50
|
+
|
51
|
+
cmd = <<-CMD
|
52
|
+
cd #{working_directory} &&
|
53
|
+
#{cmd}
|
54
|
+
CMD
|
55
|
+
|
56
|
+
# NOTE: Logging and debugging is writte to stderr
|
57
|
+
_stdin, stdout, stderr = Open3.popen3(cmd)
|
58
|
+
print stderr.read if verbose?
|
59
|
+
stdout.read
|
60
|
+
end
|
61
|
+
end
|
data/lib/octo_merge.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "octo_merge/version"
|
2
|
+
|
3
|
+
require "git"
|
4
|
+
|
5
|
+
require "octo_merge/cli"
|
6
|
+
require "octo_merge/configuration"
|
7
|
+
require "octo_merge/context"
|
8
|
+
require "octo_merge/execute"
|
9
|
+
require "octo_merge/interactive_pull_requests"
|
10
|
+
require "octo_merge/list_pull_requests"
|
11
|
+
require "octo_merge/options"
|
12
|
+
require "octo_merge/pull_request"
|
13
|
+
require "octo_merge/setup"
|
14
|
+
require "octo_merge/strategy"
|
15
|
+
|
16
|
+
module OctoMerge
|
17
|
+
class << self
|
18
|
+
def run(repo:, pull_request_numbers:, working_directory:, strategy:)
|
19
|
+
context = Context.new(
|
20
|
+
working_directory: working_directory,
|
21
|
+
repo: repo,
|
22
|
+
pull_request_numbers: pull_request_numbers
|
23
|
+
)
|
24
|
+
|
25
|
+
Execute.new(context: context, strategy: strategy).run
|
26
|
+
end
|
27
|
+
|
28
|
+
def configure
|
29
|
+
@github_client = nil
|
30
|
+
yield(configuration)
|
31
|
+
end
|
32
|
+
|
33
|
+
def configuration
|
34
|
+
@configuration ||= Configuration.new
|
35
|
+
end
|
36
|
+
|
37
|
+
def github_client
|
38
|
+
@github_client ||= Octokit::Client.new(
|
39
|
+
login: configuration.login,
|
40
|
+
password: configuration.password
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "octo_merge/cli/parser"
|
2
|
+
|
3
|
+
module OctoMerge
|
4
|
+
class CLI
|
5
|
+
attr_reader :args
|
6
|
+
|
7
|
+
def self.run(*args)
|
8
|
+
new(*args).run
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(args)
|
12
|
+
@args = args
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
configure
|
17
|
+
|
18
|
+
if options.setup
|
19
|
+
setup
|
20
|
+
else
|
21
|
+
execute
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def configure
|
28
|
+
OctoMerge.configure do |config|
|
29
|
+
config.login = options.login
|
30
|
+
config.password = options.password
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup
|
35
|
+
Setup.run(options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute
|
39
|
+
OctoMerge.run(
|
40
|
+
pull_request_numbers: options.pull_requests,
|
41
|
+
repo: options.repo,
|
42
|
+
strategy: options.strategy,
|
43
|
+
working_directory: options.dir
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
def options
|
48
|
+
@options ||= Options.new.tap do |options|
|
49
|
+
options.cli_options = Parser.parse(args)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|