mergeq 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/mergeq +3 -0
- data/bin/mergeq.sh +127 -0
- data/bin/mergeq_ci +3 -0
- data/bin/mergeq_ci.sh +52 -0
- data/lib/mergeq.rb +5 -0
- data/lib/mergeq/version.rb +3 -0
- data/mergeq.gemspec +17 -0
- metadata +63 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Aaron Jensen
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Mergeq
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'mergeq'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install mergeq
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/mergeq
ADDED
data/bin/mergeq.sh
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
target_branch=${1:-"integration"}
|
3
|
+
merge_branch=${2:-"merge/$target_branch"}
|
4
|
+
|
5
|
+
function status {
|
6
|
+
echo "// $1"
|
7
|
+
}
|
8
|
+
|
9
|
+
function exit_if_local_mods {
|
10
|
+
if [ ! -z "$(git status --porcelain)" ] ; then
|
11
|
+
status "Local modifications detected. Cannot push."
|
12
|
+
git status -s
|
13
|
+
exit 1
|
14
|
+
fi
|
15
|
+
|
16
|
+
return 0
|
17
|
+
}
|
18
|
+
|
19
|
+
function merge_failed {
|
20
|
+
status "Doh. Your merge has conflicts, but don\'t worry:"
|
21
|
+
echo
|
22
|
+
echo 1. Fix your merge conflicts
|
23
|
+
echo 2. Commit them
|
24
|
+
echo 3. Run mergeq again
|
25
|
+
|
26
|
+
exit 1
|
27
|
+
}
|
28
|
+
|
29
|
+
function checkout_target_branch {
|
30
|
+
status "Checking out $target_branch..."
|
31
|
+
|
32
|
+
git fetch origin $target_branch
|
33
|
+
git checkout -q FETCH_HEAD
|
34
|
+
git reset --hard
|
35
|
+
git clean -f
|
36
|
+
}
|
37
|
+
|
38
|
+
function cleanup {
|
39
|
+
echo "
|
40
|
+
Returning to $branch..."
|
41
|
+
git checkout -q $branch
|
42
|
+
rm .merging
|
43
|
+
}
|
44
|
+
|
45
|
+
function try_to_merge {
|
46
|
+
status "Merging $branch into $target_branch"
|
47
|
+
|
48
|
+
git merge --no-ff $branch -m "Merge $branch into $target_branch" || merge_failed
|
49
|
+
}
|
50
|
+
|
51
|
+
function write_temp_file {
|
52
|
+
status "Writing temp file..."
|
53
|
+
echo "$branch;$merge_branch;$target_branch" > .merging
|
54
|
+
}
|
55
|
+
|
56
|
+
function start_merge {
|
57
|
+
status "Starting merge..."
|
58
|
+
set -e
|
59
|
+
|
60
|
+
exit_if_local_mods
|
61
|
+
|
62
|
+
branch=`git rev-parse --abbrev-ref HEAD`
|
63
|
+
|
64
|
+
checkout_target_branch
|
65
|
+
write_temp_file
|
66
|
+
try_to_merge
|
67
|
+
|
68
|
+
continue_merge
|
69
|
+
}
|
70
|
+
|
71
|
+
function push_failed {
|
72
|
+
status "Your push failed, someone may have beat you. Try again?"
|
73
|
+
}
|
74
|
+
|
75
|
+
function exit_if_we_have_already_been_merged {
|
76
|
+
set +e
|
77
|
+
git fetch origin $target_branch
|
78
|
+
git diff --quiet FETCH_HEAD
|
79
|
+
if [ $? -eq 0 ]
|
80
|
+
then
|
81
|
+
echo "
|
82
|
+
**********************************************************
|
83
|
+
|
84
|
+
This branch has already been merged into $target_branch
|
85
|
+
|
86
|
+
**********************************************************"
|
87
|
+
cleanup
|
88
|
+
exit 1
|
89
|
+
fi
|
90
|
+
set -e
|
91
|
+
}
|
92
|
+
|
93
|
+
function push_to_merge_branch {
|
94
|
+
current=`git rev-parse HEAD`
|
95
|
+
|
96
|
+
status "Merging into $merge_branch"
|
97
|
+
git fetch origin $merge_branch
|
98
|
+
git checkout -q FETCH_HEAD
|
99
|
+
git merge --no-ff -s ours --no-commit $current
|
100
|
+
echo $current > .merge
|
101
|
+
git add .merge
|
102
|
+
git commit -m "Queuing merge: $branch into $target_branch"
|
103
|
+
status "Queuing merge by pushing $merge_branch"
|
104
|
+
git push origin HEAD:refs/heads/$merge_branch || push_failed
|
105
|
+
}
|
106
|
+
|
107
|
+
function continue_merge {
|
108
|
+
exit_if_local_mods
|
109
|
+
exit_if_we_have_already_been_merged
|
110
|
+
push_to_merge_branch
|
111
|
+
|
112
|
+
status "Done!"
|
113
|
+
cleanup
|
114
|
+
}
|
115
|
+
|
116
|
+
if [ -f .merging ]
|
117
|
+
then
|
118
|
+
IFS=';' read -ra branches < .merging
|
119
|
+
branch=${branches[0]}
|
120
|
+
merge_branch=${branches[1]}
|
121
|
+
target_branch=${branches[2]}
|
122
|
+
|
123
|
+
status "Continuing merge..."
|
124
|
+
continue_merge
|
125
|
+
else
|
126
|
+
start_merge
|
127
|
+
fi
|
data/bin/mergeq_ci
ADDED
data/bin/mergeq_ci.sh
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
action=$1
|
4
|
+
|
5
|
+
function print_usage_and_exit {
|
6
|
+
echo "Usage: mergeq_ci <merge|push> [target-branch]"
|
7
|
+
exit 1
|
8
|
+
}
|
9
|
+
|
10
|
+
|
11
|
+
function checkout_target_branch {
|
12
|
+
git fetch origin $target_branch
|
13
|
+
git checkout -q FETCH_HEAD
|
14
|
+
git reset --hard
|
15
|
+
git clean -df
|
16
|
+
}
|
17
|
+
|
18
|
+
function merge_branch_into_target_branch {
|
19
|
+
# This ends up looking like a new merge regardless
|
20
|
+
# of whether or not we can fast forward merge.
|
21
|
+
# and it copies over any merge conflict resolutions.
|
22
|
+
# It's clearly black magic.
|
23
|
+
git merge --no-ff --no-commit $head
|
24
|
+
echo `git rev-parse $head^2` > .git/MERGE_HEAD
|
25
|
+
}
|
26
|
+
|
27
|
+
function commit_merge {
|
28
|
+
message=`git log -1 --pretty=%s $head`
|
29
|
+
git commit -m "$message"
|
30
|
+
}
|
31
|
+
|
32
|
+
function merge {
|
33
|
+
head=`git rev-parse HEAD^2`
|
34
|
+
|
35
|
+
checkout_target_branch
|
36
|
+
merge_branch_into_target_branch
|
37
|
+
commit_merge
|
38
|
+
}
|
39
|
+
|
40
|
+
function push {
|
41
|
+
git push origin HEAD:$target_branch
|
42
|
+
}
|
43
|
+
|
44
|
+
target_branch=${2:-"integration"}
|
45
|
+
|
46
|
+
if [ "$action" = "merge" ] ; then
|
47
|
+
merge
|
48
|
+
elif [ "$action" = "push" ] ; then
|
49
|
+
push
|
50
|
+
else
|
51
|
+
print_usage_and_exit
|
52
|
+
fi
|
data/lib/mergeq.rb
ADDED
data/mergeq.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/mergeq/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Aaron Jensen"]
|
6
|
+
gem.email = ["aaronjensen@gmail.com"]
|
7
|
+
gem.description = %q{A set of scripts that enable merging after build. Useful if you'd rather run your tests on TeamCity.}
|
8
|
+
gem.summary = %q{Get your CI (like TeamCity) to merge after builds pass with a queue of gated merges.}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "mergeq"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Mergeq::VERSION
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mergeq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Aaron Jensen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-13 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A set of scripts that enable merging after build. Useful if you'd rather
|
15
|
+
run your tests on TeamCity.
|
16
|
+
email:
|
17
|
+
- aaronjensen@gmail.com
|
18
|
+
executables:
|
19
|
+
- mergeq
|
20
|
+
- mergeq.sh
|
21
|
+
- mergeq_ci
|
22
|
+
- mergeq_ci.sh
|
23
|
+
extensions: []
|
24
|
+
extra_rdoc_files: []
|
25
|
+
files:
|
26
|
+
- .gitignore
|
27
|
+
- Gemfile
|
28
|
+
- LICENSE
|
29
|
+
- README.md
|
30
|
+
- Rakefile
|
31
|
+
- bin/mergeq
|
32
|
+
- bin/mergeq.sh
|
33
|
+
- bin/mergeq_ci
|
34
|
+
- bin/mergeq_ci.sh
|
35
|
+
- lib/mergeq.rb
|
36
|
+
- lib/mergeq/version.rb
|
37
|
+
- mergeq.gemspec
|
38
|
+
homepage: ''
|
39
|
+
licenses: []
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 1.8.23
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: Get your CI (like TeamCity) to merge after builds pass with a queue of gated
|
62
|
+
merges.
|
63
|
+
test_files: []
|