octo_merge 0.2.0 → 0.3.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/exe/octo-merge +11 -4
- data/lib/octo_merge/git.rb +1 -0
- data/lib/octo_merge/merge_with_rebase_and_message.rb +87 -0
- data/lib/octo_merge/pull_request.rb +12 -0
- data/lib/octo_merge/version.rb +1 -1
- data/lib/octo_merge.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d04807b8aa3b52cc6ba26b896fd4c293a6ce2b15
|
4
|
+
data.tar.gz: f61a9911d245112f1e2db1e324fd32d110a29f6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be5dcf239a003519014f413e5024ecb5d9df799d736df2394de0bf428e90481fcb4f86e49c002d6339808fd99166c2d275a6713eb65fa679475818b74cec8772
|
7
|
+
data.tar.gz: 8f3534fe23b033a617f23fbffd6d40f5d781dc98ba6fb7404f05dace046328b16b526101028ede993d142495f09969080044b65d4fc3d831662c4a24a5f565be
|
data/exe/octo-merge
CHANGED
@@ -4,11 +4,18 @@ require "optparse"
|
|
4
4
|
require "octo_merge"
|
5
5
|
require "yaml"
|
6
6
|
|
7
|
-
options =
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
user_config_path = File.expand_path("~/.octo-merge.yml")
|
10
|
+
|
11
|
+
if File.exist?(user_config_path)
|
12
|
+
body = File.read(user_config_path)
|
13
|
+
options.merge!(YAML.load(body))
|
14
|
+
end
|
15
|
+
|
16
|
+
if File.exist?(".octo-merge.yml")
|
8
17
|
body = File.read(".octo-merge.yml")
|
9
|
-
YAML.load(body)
|
10
|
-
else
|
11
|
-
{}
|
18
|
+
options.merge!(YAML.load(body))
|
12
19
|
end
|
13
20
|
|
14
21
|
# Symbolize keys
|
data/lib/octo_merge/git.rb
CHANGED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
module OctoMerge
|
4
|
+
class MergeWithRebaseAndMessage < AbstractMerge
|
5
|
+
def run
|
6
|
+
git.checkout(master)
|
7
|
+
git.fetch(upstream)
|
8
|
+
git.reset_hard("#{upstream}/#{master}")
|
9
|
+
|
10
|
+
pull_requests.each do |pull_request|
|
11
|
+
git.remote_add("#{pull_request.remote} #{pull_request.remote_url}")
|
12
|
+
git.fetch(pull_request.remote)
|
13
|
+
git.checkout(pull_request.branch)
|
14
|
+
git.rebase(master)
|
15
|
+
git.checkout(master)
|
16
|
+
git.merge_no_ff(pull_request.branch)
|
17
|
+
|
18
|
+
add_merge_message(pull_request)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
# TODO: Can we add a custom message to a merge commit in an easier way?
|
25
|
+
#
|
26
|
+
# Note: It's hard to add a multiline message with `merge --message`.
|
27
|
+
#
|
28
|
+
# The `--file` options does not work for `git --merge` so we abuse
|
29
|
+
# `git commit --amend` to apply this message to the merge commit.
|
30
|
+
def add_merge_message(pull_request)
|
31
|
+
MergeMessageFile.path_for(pull_request) do |path|
|
32
|
+
git.commit("--amend --file=#{path}")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class MergeMessageFile
|
37
|
+
def initialize(pull_request)
|
38
|
+
@pull_request = pull_request
|
39
|
+
file.write(body)
|
40
|
+
file.close
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.path_for(pull_request)
|
44
|
+
new(pull_request).tap do |file|
|
45
|
+
yield(file.path)
|
46
|
+
file.delete
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def path
|
51
|
+
file.path
|
52
|
+
end
|
53
|
+
|
54
|
+
def delete
|
55
|
+
file.unlink
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
attr_reader :pull_request
|
61
|
+
|
62
|
+
def file
|
63
|
+
@file ||= Tempfile.new('merge_commit_message')
|
64
|
+
end
|
65
|
+
|
66
|
+
def body
|
67
|
+
sanitize <<-BODY
|
68
|
+
Merge branch '#{pull_request.branch}'
|
69
|
+
|
70
|
+
Resolves and closes: #{pull_request.url}
|
71
|
+
|
72
|
+
= #{pull_request.title}
|
73
|
+
|
74
|
+
#{pull_request.body}
|
75
|
+
BODY
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def sanitize(body)
|
80
|
+
# Replace leading "#" and replace with "="
|
81
|
+
body.gsub(/^#+/) { |s| "=" * s.length }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
private_constant :MergeMessageFile
|
86
|
+
end
|
87
|
+
end
|
@@ -9,6 +9,10 @@ module OctoMerge
|
|
9
9
|
@number = number.to_s
|
10
10
|
end
|
11
11
|
|
12
|
+
def url
|
13
|
+
github_api_result.html_url
|
14
|
+
end
|
15
|
+
|
12
16
|
def remote
|
13
17
|
github_api_result.user.login
|
14
18
|
end
|
@@ -21,6 +25,14 @@ module OctoMerge
|
|
21
25
|
github_api_result.head.ref
|
22
26
|
end
|
23
27
|
|
28
|
+
def title
|
29
|
+
github_api_result.title
|
30
|
+
end
|
31
|
+
|
32
|
+
def body
|
33
|
+
github_api_result.body
|
34
|
+
end
|
35
|
+
|
24
36
|
def ==(other_pull_request)
|
25
37
|
repo == other_pull_request.repo && number == other_pull_request.number
|
26
38
|
end
|
data/lib/octo_merge/version.rb
CHANGED
data/lib/octo_merge.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octo_merge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Helm
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- lib/octo_merge/interactive_pull_requests.rb
|
138
138
|
- lib/octo_merge/list_pull_requests.rb
|
139
139
|
- lib/octo_merge/merge_with_rebase.rb
|
140
|
+
- lib/octo_merge/merge_with_rebase_and_message.rb
|
140
141
|
- lib/octo_merge/merge_without_rebase.rb
|
141
142
|
- lib/octo_merge/pull_request.rb
|
142
143
|
- lib/octo_merge/version.rb
|