git-contest 0.2.4 → 0.2.5
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 +8 -8
- data/.travis.yml +21 -3
- data/README.md +5 -0
- data/Rakefile +8 -0
- data/appveyor.yml +21 -0
- data/bin/git-contest +4 -33
- data/bin/git-contest-config +4 -241
- data/bin/git-contest-finish +4 -151
- data/bin/git-contest-init +4 -65
- data/bin/git-contest-list +4 -64
- data/bin/git-contest-rebase +4 -64
- data/bin/git-contest-start +4 -57
- data/bin/git-contest-submit +4 -183
- data/git-contest.gemspec +2 -1
- data/lib/contest/driver/base.rb +7 -4
- data/lib/git/contest/command_line.rb +10 -0
- data/lib/git/contest/command_line/command.rb +117 -0
- data/lib/git/contest/command_line/main_command.rb +56 -0
- data/lib/git/contest/command_line/sub_commands.rb +35 -0
- data/lib/git/contest/command_line/sub_commands/config_command.rb +258 -0
- data/lib/git/contest/command_line/sub_commands/finish_command.rb +161 -0
- data/lib/git/contest/command_line/sub_commands/init_command.rb +79 -0
- data/lib/git/contest/command_line/sub_commands/list_command.rb +89 -0
- data/lib/git/contest/command_line/sub_commands/rebase_command.rb +87 -0
- data/lib/git/contest/command_line/sub_commands/start_command.rb +77 -0
- data/lib/git/contest/command_line/sub_commands/submit_command.rb +220 -0
- data/lib/git/contest/common.rb +6 -6
- data/lib/git/contest/git.rb +160 -156
- data/lib/git/contest/version.rb +1 -1
- data/spec/command/t004_git_contest_submit_spec.rb +254 -0
- data/spec/command/t005_git_contest_branching_spec.rb +90 -0
- data/spec/command/t007_git_contest_start_spec.rb +95 -0
- data/spec/command/t008_git_contest_finish_spec.rb +171 -0
- data/spec/command/t009_git_contest_init_spec.rb +85 -0
- data/spec/command/t012_git_contest_list_spec.rb +123 -0
- data/spec/command/t013_git_contest_config_spec.rb +186 -0
- data/spec/{lib/contest/driver → contest_driver}/t001_aizu_online_judge_spec.rb +1 -1
- data/spec/{lib/contest/driver → contest_driver}/t002_codeforces_spec.rb +1 -1
- data/spec/{lib/contest/driver → contest_driver}/t003_uva_online_judge_spec.rb +1 -1
- data/spec/{lib/contest/driver → contest_driver}/t010_kattis_spec.rb +1 -1
- data/spec/{lib/contest/driver → contest_driver}/t011_utils_spec.rb +0 -0
- data/spec/spec_helper.rb +18 -12
- data/spec/t006_config_spec.rb +37 -31
- metadata +57 -33
- data/spec/bin/t004_git_contest_submit_spec.rb +0 -223
- data/spec/bin/t005_git_contest_branching_spec.rb +0 -70
- data/spec/bin/t007_git_contest_start_spec.rb +0 -88
- data/spec/bin/t008_git_contest_finish_spec.rb +0 -162
- data/spec/bin/t009_git_contest_init_spec.rb +0 -55
- data/spec/bin/t012_git_contest_list_spec.rb +0 -99
- data/spec/bin/t013_git_contest_config_spec.rb +0 -149
- data/spec/spec_list.txt +0 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODQ5ZTNkNDU1NGQ2ZDRjMzNmZGFiMDA4MGRjZWZhOTAyOWMxY2IzNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2IxY2NlNTE3YzM4ZTZkODczNGVkY2ZkMjgzZmZlN2Q4ZjQ3N2EyZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTc0NzdjODQ1Y2YxZWE4MDQ4OGUxOWZlNzU1NDVhYTE4OTAwNTU4MzlmMThl
|
10
|
+
NDY5Nzg2MDIzY2M0OWIxNTA4MTE0YTZhNTVjZWQwMDE3NmE5NDQzNDU0MjVj
|
11
|
+
YTU3YmY3NGQxNzE2ZGI1ZWRmZjRlMGE1MTU4YjhjYzM4MDNmNWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmViMThlMmExYmI5ZTY1Zjc3MGI0ZDJiNTQ4ZTMyNDdkYzY2NWY5Nzc3Njcy
|
14
|
+
M2ViODNjMWMzNTkzNzQwY2RjZWIyYmQwYmZjNTJkNzUzNDNiN2IxNTI4Zjk2
|
15
|
+
YTkzNWNhZmY1ZGJiOGM5M2I0NzE5NDRhNGM0YjMzOWI4NzJhZDk=
|
data/.travis.yml
CHANGED
@@ -1,27 +1,45 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
3
|
rvm:
|
4
|
+
- "2.2"
|
4
5
|
- "2.1"
|
5
6
|
- "2.0"
|
6
7
|
- "1.9"
|
7
8
|
|
9
|
+
sudo: false
|
10
|
+
|
8
11
|
before_install:
|
9
12
|
- git config --global user.email "dummy@localhost"
|
10
13
|
- git config --global user.name "This Is Dummyyy"
|
11
14
|
|
12
15
|
install:
|
13
|
-
-
|
14
|
-
- travis_retry bundle install --jobs
|
16
|
+
- bundle config build.nokogiri --use-system-libraries
|
17
|
+
- travis_retry bundle install --jobs 4 --path vendor/bundle
|
15
18
|
- bundle exec rake install
|
16
19
|
|
17
20
|
script:
|
18
21
|
- bundle exec rake spec
|
19
22
|
|
23
|
+
cache:
|
24
|
+
directories:
|
25
|
+
- vendor/bundle
|
26
|
+
|
20
27
|
deploy:
|
21
28
|
provider: rubygems
|
22
29
|
api_key:
|
23
30
|
master:
|
24
|
-
secure:
|
31
|
+
secure: LjL6NrPR/KdkSKgUgixtsWiPH7LZrgZrMG9d66G0CY1HLDUXOY17W7HyAP0PYFVLVrJDM7CRx66PSuadYtyuIY1s0iM5hpEA81MlenxZQoApGcbJb2Zd647SPNk4NM+mZCRt9xJyRqrvHHg1d5+4pQVSHl/lGvuQRGXrYXocGLg=
|
25
32
|
gem:
|
26
33
|
master: git-contest
|
27
34
|
|
35
|
+
notifications:
|
36
|
+
slack:
|
37
|
+
secure: I9NClP5cpphb55oc1n7rNEUyxDIKbVBl2F2BrHOsnvWgAYKtNv//rEtkenwouEfXLeKc8UrmM4WhM6JbT04QbHnsxZzMpUJp4du/r/8SoTWpBRN/TKYKsbUCMWp0PHYN5G/cgVrnRm1zbSaxjliMgUhNiZDBPUP9bEA5XvuAVNY=
|
38
|
+
|
39
|
+
webhooks:
|
40
|
+
urls:
|
41
|
+
# gitter
|
42
|
+
secure: "HR3uIFiN/vzmXFnUJLa2ie7dQcaZw4zOXqULyQqHewGSU/nrwHNCchWSWFJJOLlRtqcxWnOrDm4V9eTXgCqLLpCn10xrAqHRfZ8ZusO+2dc3RyCz6yc+ftwil9NK3RkZ7/J/T0ox1ElE6ARzqMtVQ9nJp309Xsh0zCLjDN7LBB8="
|
43
|
+
on_success: always # options: [always|never|change] default: always
|
44
|
+
on_failure: always # options: [always|never|change] default: always
|
45
|
+
on_start: true # default: false
|
data/README.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
|
4
4
|
[](http://badge.fury.io/rb/git-contest)
|
5
5
|
[](https://travis-ci.org/sh19910711/git-contest)
|
6
|
+
[](https://codeclimate.com/github/sh19910711/git-contest)
|
7
|
+
[](https://codeclimate.com/github/sh19910711/git-contest)
|
8
|
+
[](https://gitter.im/sh19910711/git-contest?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
6
9
|
|
7
10
|
Currently support the following online judges:
|
8
11
|
|
@@ -199,6 +202,8 @@ to be written here.
|
|
199
202
|
* Added Kattis Driver
|
200
203
|
* [Wei Jianwen](https://github.com/weijianwen)
|
201
204
|
* Fixed gem dependency
|
205
|
+
* [takuti](https://github.com/takuti)
|
206
|
+
* Fixed for python support in AOJ Driver
|
202
207
|
|
203
208
|
## License Information
|
204
209
|
**git-contest** is licensed under the MIT-License, see details followings:
|
data/Rakefile
CHANGED
data/appveyor.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
version: "{build}"
|
2
|
+
|
3
|
+
environment:
|
4
|
+
matrix:
|
5
|
+
- ruby_version: "21"
|
6
|
+
- ruby_version: "200"
|
7
|
+
- ruby_version: "193"
|
8
|
+
|
9
|
+
cache:
|
10
|
+
- vendor/bundle
|
11
|
+
|
12
|
+
install:
|
13
|
+
- cmd: git config --global user.email "dummy@localhost"
|
14
|
+
- cmd: git config --global user.name "This Is Dummyyy"
|
15
|
+
- cmd: bundle install --path vendor/bundle
|
16
|
+
|
17
|
+
test_script:
|
18
|
+
- cmd: bundle exec rake spec
|
19
|
+
|
20
|
+
build: "off"
|
21
|
+
|
data/bin/git-contest
CHANGED
@@ -8,38 +8,9 @@
|
|
8
8
|
# Licensed under the MIT-License.
|
9
9
|
#
|
10
10
|
|
11
|
-
|
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 " %-12s Show information (sites, drivers)." % ["list"]
|
24
|
-
puts " %-12s Get/Set a config value." % ["config"]
|
25
|
-
puts ""
|
26
|
-
puts "Try 'git contest <subcommand> help' for details."
|
27
|
-
end
|
28
|
-
|
29
|
-
init
|
30
|
-
|
31
|
-
sub_commands = %w(init start finish submit rebase list config)
|
32
|
-
global_opts = Trollop::options do
|
33
|
-
version "git-contest #{Git::Contest::VERSION} (c) 2013-2014 Hiroyuki Sano"
|
34
|
-
stop_on sub_commands
|
35
|
-
end
|
36
|
-
|
37
|
-
cmd = ARGV.shift
|
38
|
-
case cmd
|
39
|
-
when "init", "start", "finish", "submit", "rebase", "list", "config"
|
40
|
-
load File.expand_path("../git-contest-#{cmd}", __FILE__)
|
41
|
-
else
|
42
|
-
usage
|
43
|
-
end
|
11
|
+
require_relative "../lib/git/contest/command_line"
|
44
12
|
|
13
|
+
cli = CommandLine::MainCommand.new(ARGV)
|
14
|
+
cli.init
|
15
|
+
cli.run
|
45
16
|
|
data/bin/git-contest-config
CHANGED
@@ -8,247 +8,10 @@
|
|
8
8
|
# Licensed under the MIT-License.
|
9
9
|
#
|
10
10
|
|
11
|
-
|
12
|
-
require 'git/contest/common'
|
13
|
-
require 'trollop'
|
14
|
-
require 'highline/import'
|
15
|
-
require 'active_support/core_ext/hash'
|
11
|
+
require_relative "../lib/git/contest/command_line"
|
16
12
|
|
13
|
+
cli = CommandLine::SubCommands::ConfigCommand.new ARGV
|
14
|
+
cli.init
|
15
|
+
cli.run
|
17
16
|
|
18
|
-
# Show Banner
|
19
|
-
def usage
|
20
|
-
puts get_banner
|
21
|
-
return 0
|
22
|
-
end
|
23
|
-
|
24
|
-
def show_get_usage
|
25
|
-
res = ""
|
26
|
-
res += "usage: git contest config get [key]\n"
|
27
|
-
res += "\n"
|
28
|
-
res += "Example Usage:\n"
|
29
|
-
res += " $ git contest config get key1\n"
|
30
|
-
res += " $ git contest config get namespace1.key1\n"
|
31
|
-
res += " $ git contest config get sites.some_judge.user\n"
|
32
|
-
res += " \n"
|
33
|
-
puts res
|
34
|
-
end
|
35
|
-
|
36
|
-
def show_set_usage
|
37
|
-
res = ""
|
38
|
-
res += "usage: git contest config set [key] <value>\n"
|
39
|
-
res += "\n"
|
40
|
-
res += "Example Usage:\n"
|
41
|
-
res += " $ git contest config set key1 value1\n"
|
42
|
-
res += " -> key1 = value1\n"
|
43
|
-
res += " $ git contest config set key1\n"
|
44
|
-
res += " -> set value from command-line\n"
|
45
|
-
res += " $ git contest config set namespace1.key1 value1\n"
|
46
|
-
res += " $ git contest config set sites.some_judge.user username\n"
|
47
|
-
res += " \n"
|
48
|
-
puts res
|
49
|
-
end
|
50
|
-
|
51
|
-
def show_site_usage
|
52
|
-
res = ""
|
53
|
-
res += "usage: git contest config site <type>\n"
|
54
|
-
res += "\n"
|
55
|
-
res += "Available types are:\n"
|
56
|
-
res += " %-8s: add site\n" % "add"
|
57
|
-
res += " \n"
|
58
|
-
puts res
|
59
|
-
end
|
60
|
-
|
61
|
-
def show_site_add_usage
|
62
|
-
res = ""
|
63
|
-
res += "usage: git contest config site add <site-name>\n"
|
64
|
-
res += "\n"
|
65
|
-
res += "Example Usage:\n"
|
66
|
-
res += " $ git contest config site add site1\n"
|
67
|
-
res += " -> input information\n"
|
68
|
-
res += " \n"
|
69
|
-
puts res
|
70
|
-
end
|
71
|
-
|
72
|
-
def show_site_rm_usage
|
73
|
-
res = ""
|
74
|
-
res += "usage: git contest config site rm <site-name>\n"
|
75
|
-
res += "\n"
|
76
|
-
res += "Example Usage:\n"
|
77
|
-
res += " $ git contest config site rm site1\n"
|
78
|
-
res += " \n"
|
79
|
-
puts res
|
80
|
-
end
|
81
|
-
|
82
|
-
# Get Banner Text
|
83
|
-
def get_banner
|
84
|
-
res = ""
|
85
|
-
res += "usage: git contest config [type]\n"
|
86
|
-
res += "\n"
|
87
|
-
res += "Available types are:\n"
|
88
|
-
res += " %-8s: set value\n" % "set"
|
89
|
-
res += " %-8s: get value\n" % "get"
|
90
|
-
res += " %-8s: set site info\n" % "site"
|
91
|
-
res += " \n"
|
92
|
-
return res
|
93
|
-
end
|
94
|
-
|
95
|
-
init
|
96
|
-
|
97
|
-
sub_commands = %w(sites)
|
98
|
-
$options = Trollop::options do
|
99
|
-
version "git-contest #{Git::Contest::VERSION} (c) 2013-2014 Hiroyuki Sano"
|
100
|
-
banner get_banner
|
101
|
-
stop_on sub_commands
|
102
|
-
end
|
103
|
-
|
104
|
-
type = ARGV.shift.to_s.strip
|
105
|
-
|
106
|
-
case type
|
107
|
-
|
108
|
-
when "site"
|
109
|
-
if ARGV.length >= 1
|
110
|
-
type = ARGV.shift.to_s.strip
|
111
|
-
case type
|
112
|
-
when "add"
|
113
|
-
# git-contest-config site add
|
114
|
-
if ARGV.length == 1
|
115
|
-
puts "# input site config (password will be hidden)"
|
116
|
-
|
117
|
-
# read info
|
118
|
-
site_name = ARGV.shift.to_s.strip
|
119
|
-
config = get_config
|
120
|
-
|
121
|
-
# init config
|
122
|
-
config["sites"][site_name] = {}
|
123
|
-
|
124
|
-
# input site info
|
125
|
-
# TODO: to check not found
|
126
|
-
config["sites"][site_name]["driver"] = ask("%10s > " % "driver").to_s
|
127
|
-
# TODO: to depend on above driver
|
128
|
-
config["sites"][site_name]["user"] = ask("%10s > " % "user id").to_s
|
129
|
-
config["sites"][site_name]["password"] = ask("%10s > " % "password") do |q|
|
130
|
-
q.echo = false
|
131
|
-
end.to_s
|
132
|
-
|
133
|
-
# set config
|
134
|
-
File.open($git_contest_config, 'w') {|f| f.write config.to_yaml }
|
135
|
-
|
136
|
-
puts ""
|
137
|
-
puts "updated successfully!!"
|
138
|
-
puts ""
|
139
|
-
else
|
140
|
-
show_site_add_usage
|
141
|
-
end
|
142
|
-
|
143
|
-
when "rm"
|
144
|
-
# git-contest-config site rm
|
145
|
-
if ARGV.length == 1
|
146
|
-
# TODO: to check not found
|
147
|
-
site_name = ARGV.shift.to_s.strip
|
148
|
-
|
149
|
-
puts "Are you sure you want to remove `#{site_name}`?"
|
150
|
-
this_is_yes = ask("when you remove the site, type `yes` > ").to_s
|
151
|
-
|
152
|
-
if this_is_yes == "yes"
|
153
|
-
# update config
|
154
|
-
config = get_config
|
155
|
-
config["sites"].delete site_name
|
156
|
-
# save config
|
157
|
-
File.open($git_contest_config, 'w') {|f| f.write config.to_yaml }
|
158
|
-
puts ""
|
159
|
-
puts "updated successfully!!"
|
160
|
-
puts ""
|
161
|
-
else
|
162
|
-
puts ""
|
163
|
-
puts "operation cancelled"
|
164
|
-
puts ""
|
165
|
-
end
|
166
|
-
else
|
167
|
-
show_site_rm_usage
|
168
|
-
end
|
169
|
-
|
170
|
-
else
|
171
|
-
show_site_usage
|
172
|
-
end
|
173
|
-
else
|
174
|
-
show_site_usage
|
175
|
-
end
|
176
|
-
|
177
|
-
when "get"
|
178
|
-
if ARGV.length == 1
|
179
|
-
# read key
|
180
|
-
config = get_config
|
181
|
-
cur = config
|
182
|
-
keys = ARGV.shift.to_s.strip.split('.')
|
183
|
-
while ! keys.empty?
|
184
|
-
key = keys.shift
|
185
|
-
if cur.has_key? key
|
186
|
-
cur = cur[key]
|
187
|
-
else
|
188
|
-
abort "ERROR: Not Found"
|
189
|
-
end
|
190
|
-
end
|
191
|
-
# output
|
192
|
-
if cur.is_a? Hash
|
193
|
-
puts "keys = #{cur.keys.join(', ')}"
|
194
|
-
else
|
195
|
-
puts cur
|
196
|
-
end
|
197
|
-
else
|
198
|
-
show_get_usage
|
199
|
-
end
|
200
|
-
|
201
|
-
when "set"
|
202
|
-
if ARGV.length == 1
|
203
|
-
# read values
|
204
|
-
keys = ARGV.shift.to_s.strip.split('.')
|
205
|
-
puts "input value"
|
206
|
-
value = gets.strip
|
207
|
-
|
208
|
-
# update yaml value
|
209
|
-
config = get_config
|
210
|
-
new_config = {}
|
211
|
-
cur = new_config
|
212
|
-
while ! keys.empty?
|
213
|
-
key = keys.shift
|
214
|
-
if keys.empty?
|
215
|
-
cur[key] = value
|
216
|
-
else
|
217
|
-
cur[key] = {}
|
218
|
-
cur = cur[key]
|
219
|
-
end
|
220
|
-
end
|
221
|
-
config.deep_merge! new_config
|
222
|
-
|
223
|
-
# save file
|
224
|
-
File.open($git_contest_config, 'w') {|f| f.write config.to_yaml }
|
225
|
-
elsif ARGV.length == 2
|
226
|
-
# read values from command args
|
227
|
-
keys = ARGV.shift.to_s.strip.split('.')
|
228
|
-
value = ARGV.shift.to_s.strip
|
229
|
-
|
230
|
-
# update yaml value
|
231
|
-
config = get_config
|
232
|
-
new_config = {}
|
233
|
-
cur = new_config
|
234
|
-
while ! keys.empty?
|
235
|
-
key = keys.shift
|
236
|
-
if keys.empty?
|
237
|
-
cur[key] = value
|
238
|
-
else
|
239
|
-
cur[key] = {}
|
240
|
-
cur = cur[key]
|
241
|
-
end
|
242
|
-
end
|
243
|
-
config.deep_merge! new_config
|
244
|
-
|
245
|
-
# save file
|
246
|
-
File.open($git_contest_config, 'w') {|f| f.write config.to_yaml }
|
247
|
-
else
|
248
|
-
show_set_usage
|
249
|
-
end
|
250
|
-
|
251
|
-
else
|
252
|
-
usage
|
253
|
-
end
|
254
17
|
|
data/bin/git-contest-finish
CHANGED
@@ -8,156 +8,9 @@
|
|
8
8
|
# Licensed under the MIT-License.
|
9
9
|
#
|
10
10
|
|
11
|
-
|
12
|
-
require 'git/contest/common'
|
13
|
-
require 'trollop'
|
11
|
+
require_relative "../lib/git/contest/command_line"
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
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-2014 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
|
13
|
+
cli = CommandLine::SubCommands::FinishCommand.new(ARGV)
|
14
|
+
cli.init
|
15
|
+
cli.run
|
163
16
|
|