git-contest 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +15 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +24 -0
- data/README.md +217 -0
- data/Rakefile +4 -0
- data/bin/git-contest +43 -0
- data/bin/git-contest-finish +163 -0
- data/bin/git-contest-init +77 -0
- data/bin/git-contest-rebase +76 -0
- data/bin/git-contest-start +68 -0
- data/bin/git-contest-submit +188 -0
- data/git-contest.gemspec +34 -0
- data/lib/contest/driver.rb +15 -0
- data/lib/contest/driver/aizu_online_judge.rb +159 -0
- data/lib/contest/driver/base.rb +103 -0
- data/lib/contest/driver/codeforces.rb +196 -0
- data/lib/contest/driver/common.rb +72 -0
- data/lib/contest/driver/driver_event.rb +30 -0
- data/lib/contest/driver/uva_online_judge.rb +131 -0
- data/lib/git/contest.rb +14 -0
- data/lib/git/contest/common.rb +48 -0
- data/lib/git/contest/git.rb +189 -0
- data/lib/git/contest/test.rb +10 -0
- data/lib/git/contest/version.rb +12 -0
- data/spec/bin/t004_git_contest_submit_spec.rb +143 -0
- data/spec/bin/t005_git_contest_branching_spec.rb +83 -0
- data/spec/bin/t007_git_contest_start_spec.rb +121 -0
- data/spec/bin/t008_git_contest_finish_spec.rb +229 -0
- data/spec/bin/t009_git_contest_init_spec.rb +82 -0
- data/spec/lib/contest/driver/t001_aizu_online_judge_spec.rb +177 -0
- data/spec/lib/contest/driver/t002_codeforces_spec.rb +34 -0
- data/spec/lib/contest/driver/t003_uva_online_judge_spec.rb +33 -0
- data/spec/mock/default_config/config.yml +0 -0
- data/spec/mock/default_config/plugins/driver_dummy.rb +113 -0
- data/spec/mock/t001/002.status_log.xml +55 -0
- data/spec/mock/t001/config.yml +5 -0
- data/spec/mock/t001/description.html +48 -0
- data/spec/mock/t001/status.html +49 -0
- data/spec/mock/t001/status_log.xml +29 -0
- data/spec/mock/t002/my_submissions.html +58 -0
- data/spec/mock/t003/after_submit.html +28 -0
- data/spec/mock/t003/my_submissions.compile_error.html +160 -0
- data/spec/mock/t003/my_submissions.sent_to_judge.html +358 -0
- data/spec/mock/t004/config.yml +17 -0
- data/spec/mock/t005/001/config.yml +5 -0
- data/spec/mock/t006/001/001/001/config.yml +8 -0
- data/spec/mock/t006/001/001/002/config.yml +8 -0
- data/spec/mock/t006/001/001/003/config.yml +8 -0
- data/spec/mock/t006/001/002/001/config.yml +8 -0
- data/spec/mock/t006/001/002/002/config.yml +8 -0
- data/spec/mock/t006/001/002/003/config.yml +8 -0
- data/spec/mock/t006/001/003/001/config.yml +9 -0
- data/spec/mock/t006/001/003/002/config.yml +9 -0
- data/spec/mock/t006/001/003/003/config.yml +9 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/spec_list.txt +1 -0
- data/spec/t006_config_spec.rb +168 -0
- metadata +269 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8a0791917f34249636a1cb66ef720f16ae9c3a0b
|
4
|
+
data.tar.gz: b2fbafcfdece975ea1e5bf2e1ebfa2cbfb22d373
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6d668f10542102ceedf259f7c49d6ea163a597692527653e8325e2017371e0340f6625b6ed85629bc3e953ed739780c43b73227af1ccb348848daa59df218b53
|
7
|
+
data.tar.gz: c0884aa980b7d77bbf6ced39b0c130debfc9927807d567e6c7a052cc7c99f91f9457dee98d663ed107a746ccc6f9d34d465507a371137b5053b41223a69307c1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.0.0
|
4
|
+
- 1.9.3
|
5
|
+
- 1.9.2
|
6
|
+
before_install:
|
7
|
+
- git config --global user.email "dummy@localhost"
|
8
|
+
- git config --global user.name "This Is Dummy"
|
9
|
+
install:
|
10
|
+
- export NOKOGIRI_USE_SYSTEM_LIBRARIES="YES"
|
11
|
+
- bundle install
|
12
|
+
- bundle exec rake install
|
13
|
+
script:
|
14
|
+
- bundle exec rake spec
|
15
|
+
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Copyright (c) 2013 Hiroyuki Sano
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
data/README.md
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
# Git::Contest
|
2
|
+
**git-contest** is _the Git Extension for online judges_ (Codeforces, etc...)
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/sh19910711/git-contest.png?branch=develop)](https://travis-ci.org/sh19910711/git-contest)
|
5
|
+
|
6
|
+
Currently support the following online judges:
|
7
|
+
|
8
|
+
* Codeforces
|
9
|
+
* [http://codeforces.com/](http://codeforces.com/)
|
10
|
+
* Aizu Online Judge
|
11
|
+
* [http://judge.u-aizu.ac.jp/onlinejudge/](http://judge.u-aizu.ac.jp/onlinejudge/)
|
12
|
+
* UVa Online Judge
|
13
|
+
* [http://uva.onlinejudge.org/](http://uva.onlinejudge.org/)
|
14
|
+
|
15
|
+
## Branching Model
|
16
|
+
![image](https://googledrive.com/host/0Bz19k_5gA4wVZWJEcW1XS25NRWM/git-contest.png)
|
17
|
+
|
18
|
+
## Commit Message Examples
|
19
|
+
In this command, a commit having a judge status will be automatically created after submitting a solution to a online judge:
|
20
|
+
|
21
|
+
* `Cxdeforces 999A: Accepted`
|
22
|
+
* `Cxdeforces 999B: Wrong Answer`
|
23
|
+
* Also you can customize commit message
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
Installation process takes a step, type a following command:
|
28
|
+
|
29
|
+
$ gem install git-contest
|
30
|
+
|
31
|
+
### Requirements
|
32
|
+
Need to install:
|
33
|
+
|
34
|
+
* [Ruby](https://www.ruby-lang.org/)
|
35
|
+
* `ruby --version` >= 1.9.2
|
36
|
+
* [Git](http://git-scm.com/)
|
37
|
+
* `git --version` >= 1.7
|
38
|
+
|
39
|
+
## Command Usage
|
40
|
+
There are 4 basic sub-commands:
|
41
|
+
|
42
|
+
### init
|
43
|
+
Initialize a git repository.
|
44
|
+
|
45
|
+
$ git contest init
|
46
|
+
|
47
|
+
### start
|
48
|
+
Start a contest branch.
|
49
|
+
|
50
|
+
$ git contest start <contest-branch> [based-branch]
|
51
|
+
|
52
|
+
After this command, `<contest-branch>` is created based on `<based-branch>`.
|
53
|
+
|
54
|
+
Example:
|
55
|
+
|
56
|
+
$ git contest start cxdeforces_round_123
|
57
|
+
-> the branch `cxdeforces_round_123` is created
|
58
|
+
|
59
|
+
### finish
|
60
|
+
Finish a contest branch.
|
61
|
+
|
62
|
+
$ git contest finish <contest-branch>
|
63
|
+
|
64
|
+
After this command, `<contest-branch>` is merged into `<based-branch>`, and then removed.
|
65
|
+
|
66
|
+
Example:
|
67
|
+
|
68
|
+
$ git contest finish cxdeforces_round_123
|
69
|
+
-> the branch `cxdeforces_round_123` is merged and closed
|
70
|
+
|
71
|
+
### submit
|
72
|
+
Submit a solution to the online judge.
|
73
|
+
|
74
|
+
$ git contest submit <site>
|
75
|
+
|
76
|
+
Example:
|
77
|
+
|
78
|
+
$ git contest submit cxdeforces -c 123 -p A
|
79
|
+
-> submit a solution to cxdeforces 123A
|
80
|
+
|
81
|
+
#### Basic Options
|
82
|
+
|
83
|
+
##### Problem ID: `-p`, `--problem-id`
|
84
|
+
|
85
|
+
Type: `String`
|
86
|
+
|
87
|
+
Set problem-id, this option is used almost all sites.
|
88
|
+
|
89
|
+
$ git contest submit site -p 10000
|
90
|
+
|
91
|
+
##### Contest ID: `-c`, `--contest-id`
|
92
|
+
|
93
|
+
Type: `String`
|
94
|
+
|
95
|
+
Set contest-id, this option is used codeforces.
|
96
|
+
|
97
|
+
$ git contest submit site -c 123
|
98
|
+
|
99
|
+
##### Source File: `-s`, `--source`
|
100
|
+
|
101
|
+
Type: `String`, Default: `main.*`
|
102
|
+
|
103
|
+
Set submitting code's filename.
|
104
|
+
|
105
|
+
$ git contest submit site -s source.cpp
|
106
|
+
|
107
|
+
##### Programming Lanaguage: `-l`, `--language`
|
108
|
+
|
109
|
+
Type: `String`
|
110
|
+
|
111
|
+
Set submitting code's programming language.
|
112
|
+
|
113
|
+
$ git contest submit site -s source.cxx -l C++
|
114
|
+
|
115
|
+
When do not set this option, **git-contest** will resolve language from source filename. (`aaa.cpp` -> `C++`)
|
116
|
+
|
117
|
+
## More Documentation
|
118
|
+
Use --help option as belows:
|
119
|
+
|
120
|
+
Example 1:
|
121
|
+
|
122
|
+
$ git contest --help
|
123
|
+
|
124
|
+
Example 2:
|
125
|
+
|
126
|
+
$ git contest <sub-command> ... --help
|
127
|
+
|
128
|
+
## Configuration
|
129
|
+
### `${GIT_CONTEST_HOME}/config.yml`
|
130
|
+
Write the information of online judges to this file.
|
131
|
+
|
132
|
+
#### Example of `config.yml`
|
133
|
+
```yaml
|
134
|
+
sites:
|
135
|
+
cxdeforces:
|
136
|
+
driver: cxdeforces
|
137
|
+
user: your_cxdeforces_id
|
138
|
+
password: your_cxdeforces_password
|
139
|
+
multi_account_axj_1:
|
140
|
+
driver: axj
|
141
|
+
user: your_axj_id_1
|
142
|
+
password: your_axj_password_1
|
143
|
+
multi_account_axj_2:
|
144
|
+
driver: axj
|
145
|
+
user: your_axj_id_2
|
146
|
+
password: your_axj_password_2
|
147
|
+
uvx:
|
148
|
+
driver: uvx
|
149
|
+
user: your_uvx_id
|
150
|
+
password: your_uvx_password
|
151
|
+
```
|
152
|
+
|
153
|
+
## Contributing
|
154
|
+
|
155
|
+
1. Fork it
|
156
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
157
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
158
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
159
|
+
5. Create new Pull Request
|
160
|
+
|
161
|
+
## Links
|
162
|
+
`git-contest` is inspired by [nvie/gitflow](https://github.com/nvie/gitflow).
|
163
|
+
|
164
|
+
* A successful Git branching model
|
165
|
+
* [http://nvie.com/posts/a-successful-git-branching-model/](http://nvie.com/posts/a-successful-git-branching-model/)
|
166
|
+
* nvie/gitflow
|
167
|
+
* [https://github.com/nvie/gitflow](https://github.com/nvie/gitflow)
|
168
|
+
* ruby
|
169
|
+
* [https://www.ruby-lang.org/](https://www.ruby-lang.org/)
|
170
|
+
* git
|
171
|
+
* [http://git-scm.com/](http://git-scm.com/)
|
172
|
+
|
173
|
+
## Author Information
|
174
|
+
* [Hiroyuki Sano](http://yomogimochi.com/)
|
175
|
+
* [GitHub - sh19910711](https://github.com/sh19910711)
|
176
|
+
* [Google+](https://plus.google.com/+HiroyukiSano)
|
177
|
+
* [Twitter - @sh19910711](https://twitter.com/sh19910711)
|
178
|
+
|
179
|
+
|
180
|
+
## License Information
|
181
|
+
**git-contest** is licensed under the MIT-License, see details followings:
|
182
|
+
|
183
|
+
The MIT License (MIT)
|
184
|
+
|
185
|
+
Copyright (c) 2013 **Hiroyuki Sano** \<sh19910711 at gmail.com\>
|
186
|
+
|
187
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
188
|
+
of this software and associated documentation files (the "Software"), to deal
|
189
|
+
in the Software without restriction, including without limitation the rights
|
190
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
191
|
+
copies of the Software, and to permit persons to whom the Software is
|
192
|
+
furnished to do so, subject to the following conditions:
|
193
|
+
|
194
|
+
The above copyright notice and this permission notice shall be included in
|
195
|
+
all copies or substantial portions of the Software.
|
196
|
+
|
197
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
198
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
199
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
200
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
201
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
202
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
203
|
+
THE SOFTWARE.
|
204
|
+
|
205
|
+
## Index
|
206
|
+
* [Branching Model](#branching-model)
|
207
|
+
* [Commit Message Examples](#commit-message-examples)
|
208
|
+
* [Installation](#installation)
|
209
|
+
* [Requirements](#requirements)
|
210
|
+
* [Command Usage](#command-usage)
|
211
|
+
* [More Documentation](#more-documentation)
|
212
|
+
* [Configuration](#configuration)
|
213
|
+
* [Contributing](#contributing)
|
214
|
+
* [Links](#links)
|
215
|
+
* [Author Information](#author-information)
|
216
|
+
* [License Information](#license-information)
|
217
|
+
|
data/Rakefile
ADDED
data/bin/git-contest
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# git-contest
|
5
|
+
# https://github.com/sh19910711/git-contest
|
6
|
+
#
|
7
|
+
# Copyright (c) 2013 Hiroyuki Sano <sh19910711 at gmail.com>
|
8
|
+
# Licensed under the MIT-License.
|
9
|
+
#
|
10
|
+
|
11
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
12
|
+
require 'git/contest/common'
|
13
|
+
require 'trollop'
|
14
|
+
|
15
|
+
def usage
|
16
|
+
puts "usage: git contest <subcommand>"
|
17
|
+
puts ""
|
18
|
+
puts "Available subcommands are:"
|
19
|
+
puts " %-12s Initialize a new git repo." % ["init"]
|
20
|
+
puts " %-12s Start a new feature branch." % ["start"]
|
21
|
+
puts " %-12s Finish a feature branch." % ["finish"]
|
22
|
+
puts " %-12s Submit a solution." % ["submit"]
|
23
|
+
puts ""
|
24
|
+
puts "Try 'git contest <subcommand> help' for details."
|
25
|
+
end
|
26
|
+
|
27
|
+
init
|
28
|
+
|
29
|
+
sub_commands = %w(init start finish submit rebase)
|
30
|
+
global_opts = Trollop::options do
|
31
|
+
version "git-contest #{Git::Contest::VERSION} (c) 2013 Hiroyuki Sano"
|
32
|
+
stop_on sub_commands
|
33
|
+
end
|
34
|
+
|
35
|
+
cmd = ARGV.shift
|
36
|
+
case cmd
|
37
|
+
when "init", "start", "finish", "submit", "rebase"
|
38
|
+
load File.expand_path("../git-contest-#{cmd}", __FILE__)
|
39
|
+
else
|
40
|
+
usage
|
41
|
+
end
|
42
|
+
|
43
|
+
|
@@ -0,0 +1,163 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# git-contest-finish
|
5
|
+
# https://github.com/sh19910711/git-contest
|
6
|
+
#
|
7
|
+
# Copyright (c) 2013 Hiroyuki Sano <sh19910711 at gmail.com>
|
8
|
+
# Licensed under the MIT-License.
|
9
|
+
#
|
10
|
+
|
11
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
12
|
+
require 'git/contest/common'
|
13
|
+
require 'trollop'
|
14
|
+
|
15
|
+
def use_current_branch
|
16
|
+
current_branch = git_current_branch
|
17
|
+
if current_branch.start_with? $PREFIX
|
18
|
+
$BRANCH = current_branch.strip
|
19
|
+
$NAME = $BRANCH[$PREFIX.length+1..-1]
|
20
|
+
else
|
21
|
+
puts "The current HEAD is no feature branch."
|
22
|
+
puts "Please spefcify a <name> argument."
|
23
|
+
abort ''
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def expand_contest_branch
|
28
|
+
if ARGV.length == 0
|
29
|
+
use_current_branch
|
30
|
+
else
|
31
|
+
$NAME = ARGV[0]
|
32
|
+
$BRANCH = "#{$PREFIX}/#{$NAME}"
|
33
|
+
require_branch $BRANCH
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def helper_finish_cleanup
|
38
|
+
require_branch $BRANCH
|
39
|
+
require_clean_working_tree
|
40
|
+
|
41
|
+
if $options[:fetch]
|
42
|
+
git_do "push \"#{$ORIGIN}\" \":refs/heads/#{$BRANCH}\""
|
43
|
+
end
|
44
|
+
|
45
|
+
if ! $options[:keep]
|
46
|
+
if $options[:force_delete]
|
47
|
+
git_do "branch -D #{$BRANCH}"
|
48
|
+
else
|
49
|
+
git_do "branch -d #{$BRANCH}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
puts ""
|
54
|
+
puts "Summary of actions:"
|
55
|
+
puts "- The contest branch \"#{$BRANCH}\" was merged into \"#{$MASTER}\""
|
56
|
+
puts "- Contest branch \"#{$BRANCH}\" has been removed"
|
57
|
+
puts "- You are now on branch \"#{$MASTER}\""
|
58
|
+
puts ""
|
59
|
+
end
|
60
|
+
|
61
|
+
init
|
62
|
+
|
63
|
+
sub_commands = %w()
|
64
|
+
$options = Trollop::options do
|
65
|
+
version "git-contest #{Git::Contest::VERSION} (c) 2013 Hiroyuki Sano"
|
66
|
+
opt(
|
67
|
+
:no_edit,
|
68
|
+
"Use default commit message.",
|
69
|
+
:type => :flag,
|
70
|
+
:default => false,
|
71
|
+
:required => false,
|
72
|
+
)
|
73
|
+
opt(
|
74
|
+
:keep,
|
75
|
+
"Keep contest branch after merge.",
|
76
|
+
:type => :flag,
|
77
|
+
:default => false,
|
78
|
+
:required => false,
|
79
|
+
)
|
80
|
+
opt(
|
81
|
+
:rebase,
|
82
|
+
"Use rebase instead of merge.",
|
83
|
+
:type => :flag,
|
84
|
+
:default => false,
|
85
|
+
:required => false,
|
86
|
+
)
|
87
|
+
opt(
|
88
|
+
:force_delete,
|
89
|
+
"Force delete contest branch after finish.",
|
90
|
+
:type => :flag,
|
91
|
+
:default => false,
|
92
|
+
:required => false,
|
93
|
+
)
|
94
|
+
opt(
|
95
|
+
:squash,
|
96
|
+
"Use squash during merge.",
|
97
|
+
:type => :flag,
|
98
|
+
:default => false,
|
99
|
+
:required => false,
|
100
|
+
)
|
101
|
+
opt(
|
102
|
+
:fetch,
|
103
|
+
"Fetch from origin before finish.",
|
104
|
+
:type => :flag,
|
105
|
+
:default => false,
|
106
|
+
:required => false,
|
107
|
+
)
|
108
|
+
stop_on sub_commands
|
109
|
+
end
|
110
|
+
|
111
|
+
expand_contest_branch()
|
112
|
+
require_branch $BRANCH
|
113
|
+
|
114
|
+
require_clean_working_tree
|
115
|
+
|
116
|
+
if git_remote_branches().include?("#{$ORIGIN}/#{$BRANCH}")
|
117
|
+
if $options[:fetch]
|
118
|
+
git_do "fetch -q \"#{$ORIGIN}\" \"#{$BRANCH}\""
|
119
|
+
git_do "fetch -q \"#{$ORIGIN}\" \"#{$MASTER}\""
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
if git_remote_branches().include?("#{$ORIGIN}/#{$BRANCH}")
|
124
|
+
require_branches_equal $BRANCH, "#{$ORIGIN}/#{$BRANCH}"
|
125
|
+
end
|
126
|
+
|
127
|
+
if git_remote_branches().include?("#{$ORIGIN}/#{$MASTER}")
|
128
|
+
require_branches_equal $MASTER, "#{$ORIGIN}/#{$MASTER}"
|
129
|
+
end
|
130
|
+
|
131
|
+
merge_options = ""
|
132
|
+
if $options[:no_edit]
|
133
|
+
merge_options += " --no-edit"
|
134
|
+
end
|
135
|
+
|
136
|
+
if $options[:rebase]
|
137
|
+
ret = git_do "contest rebase \"#{$NAME}\" \"#{$MASTER}\""
|
138
|
+
exitcode = $?.to_i
|
139
|
+
if ! $?
|
140
|
+
puts "Finish was aborted due to conflicts during rebase."
|
141
|
+
exit 1
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
git_do "checkout #{$MASTER}"
|
146
|
+
if git_do("rev-list -n2 \"#{$MASTER}..#{$BRANCH}\"").lines.to_a.length == 1
|
147
|
+
git_do "merge --ff \"#{$BRANCH}\" #{merge_options}"
|
148
|
+
else
|
149
|
+
if $options[:squash]
|
150
|
+
git_do "merge --squash \"#{$BRANCH}\" #{merge_options}"
|
151
|
+
if $options[:no_edit]
|
152
|
+
git_do "commit -m 'Squashed commit'"
|
153
|
+
else
|
154
|
+
git_do "commit"
|
155
|
+
end
|
156
|
+
git_do "merge \"#{$BRANCH}\" #{merge_options}"
|
157
|
+
else
|
158
|
+
git_do "merge --no-ff \"#{$BRANCH}\" #{merge_options}"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
helper_finish_cleanup
|
163
|
+
|