git-contest 0.0.3 → 0.1.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 +13 -5
- data/.travis.yml +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +22 -25
- data/bin/git-contest +2 -2
- data/bin/git-contest-finish +2 -2
- data/bin/git-contest-init +2 -2
- data/bin/git-contest-rebase +2 -2
- data/bin/git-contest-start +2 -2
- data/bin/git-contest-submit +34 -17
- data/git-contest.gemspec +2 -2
- data/lib/contest/driver.rb +3 -0
- data/lib/contest/driver/aizu_online_judge.rb +12 -12
- data/lib/contest/driver/base.rb +44 -19
- data/lib/contest/driver/codeforces.rb +21 -15
- data/lib/contest/driver/common.rb +21 -5
- data/lib/contest/driver/driver_event.rb +1 -1
- data/lib/contest/driver/kattis.rb +168 -0
- data/lib/contest/driver/uva_online_judge.rb +14 -11
- data/lib/git/contest/version.rb +2 -2
- data/spec/bin/t004_git_contest_submit_spec.rb +143 -69
- data/spec/lib/contest/driver/t001_aizu_online_judge_spec.rb +46 -29
- data/spec/lib/contest/driver/t002_codeforces_spec.rb +185 -20
- data/spec/lib/contest/driver/t003_uva_online_judge_spec.rb +157 -10
- data/spec/lib/contest/driver/t010_kattis_spec.rb +207 -0
- data/spec/mock/default_config/plugins/driver_dummy.rb +31 -11
- data/spec/mock/t002/codeforces_after_submit.html +45 -0
- data/spec/mock/t002/codeforces_enter.html +67 -0
- data/spec/mock/t002/codeforces_submit.html +110 -0
- data/spec/mock/t002/codeforces_wait_result.html +58 -0
- data/spec/mock/t003/uva_after_quick_submit.html +17 -0
- data/spec/mock/t003/uva_home.html +39 -0
- data/spec/mock/t003/uva_my_submissions.html +111 -0
- data/spec/mock/t003/uva_quick_submit.html +67 -0
- data/spec/mock/t010/open_kattis_com_login.html +20 -0
- data/spec/mock/t010/open_kattis_com_submit.html +54 -0
- data/spec/mock/t010/open_kattis_com_user_submissions.html +28 -0
- data/spec/mock/t010/user_submission_111111.html +30 -0
- data/spec/mock/t010/user_submission_222222.html +79 -0
- data/spec/mock/t010/user_submissions.html +39 -0
- metadata +58 -27
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZGQ2NTE5NDhhOWRkNzE0NzFmZjUzNzJkNjJlYWY1OGFiNzhkOThjNw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NGM5NDUwYzU4MjY4MDM0Mjg1ZDcxZmEzZWIyNzE1ZmUxZmFjNWFjYg==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NTBjYTRhYjdmMmQ1MDJiNzNjYmQwNTdjZThmYTczNmQ5Y2JkYTZiMmE3NzY3
|
10
|
+
NjBmMmJmNzkxNzFkNDJjM2NmZTBlMTA0Mjg2Mzk0OTBmZWJmMGY3ZTMzYjAw
|
11
|
+
ZjQyM2ExYzExNjYwZWMzNDhhMWYyZmMwZTViM2M5Y2QyMGY5MzU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MzhiOTBkOWI2OTQ5Y2Q0YmQ0Y2E1OGY3Mjk0NDU1M2QyYWM1YWE0YjQzMzg0
|
14
|
+
ZTI2NGE1NTQ4MjQ4NTkwMjljYTM4NDE1YTg2ZTIyZjQ1MTU1MWViODI4NGY3
|
15
|
+
NzI5ZmRkYjFmNTE4ZTUyMjBlMGYzMDY3NmYyZjQwYzA0MzJkOWU=
|
data/.travis.yml
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -12,6 +12,8 @@ Currently support the following online judges:
|
|
12
12
|
* [http://judge.u-aizu.ac.jp/onlinejudge/](http://judge.u-aizu.ac.jp/onlinejudge/)
|
13
13
|
* UVa Online Judge
|
14
14
|
* [http://uva.onlinejudge.org/](http://uva.onlinejudge.org/)
|
15
|
+
* Kattis
|
16
|
+
* [https://open.kattis.com/](https://open.kattis.com/)
|
15
17
|
|
16
18
|
## Branching Model
|
17
19
|

|
@@ -162,6 +164,10 @@ sites:
|
|
162
164
|
driver: uva_online_judge
|
163
165
|
user: your_uva_id
|
164
166
|
password: your_uva_password
|
167
|
+
kattis:
|
168
|
+
driver: kattis
|
169
|
+
user: your_kattis_id
|
170
|
+
password: your_kattis_password
|
165
171
|
```
|
166
172
|
|
167
173
|
#### About contest drivers
|
@@ -184,31 +190,23 @@ to be written here.
|
|
184
190
|
4. Push to the branch (`git push origin my-new-feature`)
|
185
191
|
5. Create new Pull Request
|
186
192
|
|
187
|
-
##
|
188
|
-
`git-contest` is inspired by [nvie/gitflow](https://github.com/nvie/gitflow).
|
193
|
+
## Contributors
|
189
194
|
|
190
|
-
*
|
191
|
-
*
|
192
|
-
* nvie/gitflow
|
193
|
-
* [https://github.com/nvie/gitflow](https://github.com/nvie/gitflow)
|
194
|
-
* ruby
|
195
|
-
* [https://www.ruby-lang.org/](https://www.ruby-lang.org/)
|
196
|
-
* git
|
197
|
-
* [http://git-scm.com/](http://git-scm.com/)
|
195
|
+
* [Oskar Sundström](https://github.com/osund)
|
196
|
+
* Added Kattis Driver
|
198
197
|
|
199
198
|
## Author Information
|
199
|
+
|
200
200
|
* [Hiroyuki Sano](http://yomogimochi.com/)
|
201
201
|
* [GitHub - sh19910711](https://github.com/sh19910711)
|
202
202
|
* [Google+](https://plus.google.com/+HiroyukiSano)
|
203
|
-
* [Twitter - @sh19910711](https://twitter.com/sh19910711)
|
204
|
-
|
205
203
|
|
206
204
|
## License Information
|
207
205
|
**git-contest** is licensed under the MIT-License, see details followings:
|
208
206
|
|
209
207
|
The MIT License (MIT)
|
210
208
|
|
211
|
-
Copyright (c) 2013 **Hiroyuki Sano** \<sh19910711 at gmail.com\>
|
209
|
+
Copyright (c) 2013-2014 **Hiroyuki Sano** \<sh19910711 at gmail.com\>
|
212
210
|
|
213
211
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
214
212
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -228,16 +226,15 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
228
226
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
229
227
|
THE SOFTWARE.
|
230
228
|
|
231
|
-
##
|
232
|
-
|
233
|
-
|
234
|
-
*
|
235
|
-
* [
|
236
|
-
*
|
237
|
-
* [
|
238
|
-
*
|
239
|
-
* [
|
240
|
-
*
|
241
|
-
* [
|
242
|
-
* [License Information](#license-information)
|
229
|
+
## Links
|
230
|
+
`git-contest` is inspired by [nvie/gitflow](https://github.com/nvie/gitflow).
|
231
|
+
|
232
|
+
* A successful Git branching model
|
233
|
+
* [http://nvie.com/posts/a-successful-git-branching-model/](http://nvie.com/posts/a-successful-git-branching-model/)
|
234
|
+
* nvie/gitflow
|
235
|
+
* [https://github.com/nvie/gitflow](https://github.com/nvie/gitflow)
|
236
|
+
* ruby
|
237
|
+
* [https://www.ruby-lang.org/](https://www.ruby-lang.org/)
|
238
|
+
* git
|
239
|
+
* [http://git-scm.com/](http://git-scm.com/)
|
243
240
|
|
data/bin/git-contest
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# git-contest
|
5
5
|
# https://github.com/sh19910711/git-contest
|
6
6
|
#
|
7
|
-
# Copyright (c) 2013 Hiroyuki Sano <sh19910711 at gmail.com>
|
7
|
+
# Copyright (c) 2013-2014 Hiroyuki Sano <sh19910711 at gmail.com>
|
8
8
|
# Licensed under the MIT-License.
|
9
9
|
#
|
10
10
|
|
@@ -28,7 +28,7 @@ init
|
|
28
28
|
|
29
29
|
sub_commands = %w(init start finish submit rebase)
|
30
30
|
global_opts = Trollop::options do
|
31
|
-
version "git-contest #{Git::Contest::VERSION} (c) 2013 Hiroyuki Sano"
|
31
|
+
version "git-contest #{Git::Contest::VERSION} (c) 2013-2014 Hiroyuki Sano"
|
32
32
|
stop_on sub_commands
|
33
33
|
end
|
34
34
|
|
data/bin/git-contest-finish
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# git-contest-finish
|
5
5
|
# https://github.com/sh19910711/git-contest
|
6
6
|
#
|
7
|
-
# Copyright (c) 2013 Hiroyuki Sano <sh19910711 at gmail.com>
|
7
|
+
# Copyright (c) 2013-2014 Hiroyuki Sano <sh19910711 at gmail.com>
|
8
8
|
# Licensed under the MIT-License.
|
9
9
|
#
|
10
10
|
|
@@ -62,7 +62,7 @@ init
|
|
62
62
|
|
63
63
|
sub_commands = %w()
|
64
64
|
$options = Trollop::options do
|
65
|
-
version "git-contest #{Git::Contest::VERSION} (c) 2013 Hiroyuki Sano"
|
65
|
+
version "git-contest #{Git::Contest::VERSION} (c) 2013-2014 Hiroyuki Sano"
|
66
66
|
opt(
|
67
67
|
:no_edit,
|
68
68
|
"Use default commit message.",
|
data/bin/git-contest-init
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# git-contest-init
|
5
5
|
# https://github.com/sh19910711/git-contest
|
6
6
|
#
|
7
|
-
# Copyright (c) 2013 Hiroyuki Sano <sh19910711 at gmail.com>
|
7
|
+
# Copyright (c) 2013-2014 Hiroyuki Sano <sh19910711 at gmail.com>
|
8
8
|
# Licensed under the MIT-License.
|
9
9
|
#
|
10
10
|
|
@@ -17,7 +17,7 @@ init
|
|
17
17
|
|
18
18
|
sub_commands = %w()
|
19
19
|
options = Trollop::options do
|
20
|
-
version "git-contest #{Git::Contest::VERSION} (c) 2013 Hiroyuki Sano"
|
20
|
+
version "git-contest #{Git::Contest::VERSION} (c) 2013-2014 Hiroyuki Sano"
|
21
21
|
opt(
|
22
22
|
:defaults,
|
23
23
|
"Use default branch naming conventions.",
|
data/bin/git-contest-rebase
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# git-contest-rebase
|
5
5
|
# https://github.com/sh19910711/git-contest
|
6
6
|
#
|
7
|
-
# Copyright (c) 2013 Hiroyuki Sano <sh19910711 at gmail.com>
|
7
|
+
# Copyright (c) 2013-2014 Hiroyuki Sano <sh19910711 at gmail.com>
|
8
8
|
# Licensed under the MIT-License.
|
9
9
|
#
|
10
10
|
|
@@ -48,7 +48,7 @@ init
|
|
48
48
|
|
49
49
|
sub_commands = %w()
|
50
50
|
$options = Trollop::options do
|
51
|
-
version "git-contest #{Git::Contest::VERSION} (c) 2013 Hiroyuki Sano"
|
51
|
+
version "git-contest #{Git::Contest::VERSION} (c) 2013-2014 Hiroyuki Sano"
|
52
52
|
opt(
|
53
53
|
:interactive,
|
54
54
|
"Do an interactive rebase.",
|
data/bin/git-contest-start
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# git-contest-start
|
5
5
|
# https://github.com/sh19910711/git-contest
|
6
6
|
#
|
7
|
-
# Copyright (c) 2013 Hiroyuki Sano <sh19910711 at gmail.com>
|
7
|
+
# Copyright (c) 2013-2014 Hiroyuki Sano <sh19910711 at gmail.com>
|
8
8
|
# Licensed under the MIT-License.
|
9
9
|
#
|
10
10
|
|
@@ -16,7 +16,7 @@ init
|
|
16
16
|
|
17
17
|
sub_commands = %w()
|
18
18
|
options = Trollop::options do
|
19
|
-
version "git-contest #{Git::Contest::VERSION} (c) 2013 Hiroyuki Sano"
|
19
|
+
version "git-contest #{Git::Contest::VERSION} (c) 2013-2014 Hiroyuki Sano"
|
20
20
|
opt(
|
21
21
|
:fetch,
|
22
22
|
"fetch from origin before performing operation.",
|
data/bin/git-contest-submit
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# git-contest-submit
|
5
5
|
# https://github.com/sh19910711/git-contest
|
6
6
|
#
|
7
|
-
# Copyright (c) 2013 Hiroyuki Sano <sh19910711 at gmail.com>
|
7
|
+
# Copyright (c) 2013-2014 Hiroyuki Sano <sh19910711 at gmail.com>
|
8
8
|
# Licensed under the MIT-License.
|
9
9
|
#
|
10
10
|
|
@@ -12,14 +12,6 @@ $:.unshift File.expand_path('../../lib', __FILE__)
|
|
12
12
|
require 'git/contest/common'
|
13
13
|
require 'trollop'
|
14
14
|
|
15
|
-
init
|
16
|
-
|
17
|
-
$config = get_config() || {}
|
18
|
-
$sites = {}
|
19
|
-
if $config.has_key? 'sites'
|
20
|
-
$sites = $config["sites"]
|
21
|
-
end
|
22
|
-
|
23
15
|
#
|
24
16
|
# Load Plugins
|
25
17
|
#
|
@@ -30,8 +22,6 @@ def load_plugins
|
|
30
22
|
end
|
31
23
|
end
|
32
24
|
|
33
|
-
load_plugins
|
34
|
-
|
35
25
|
#
|
36
26
|
# Load Drivers
|
37
27
|
#
|
@@ -45,9 +35,6 @@ def load_drivers
|
|
45
35
|
end
|
46
36
|
end
|
47
37
|
|
48
|
-
$drivers = {}
|
49
|
-
load_drivers
|
50
|
-
|
51
38
|
#
|
52
39
|
# Command Utils
|
53
40
|
#
|
@@ -80,10 +67,23 @@ def get_git_add_target rule
|
|
80
67
|
str
|
81
68
|
end
|
82
69
|
|
70
|
+
init
|
71
|
+
|
72
|
+
$config = get_config() || {}
|
73
|
+
$sites = {}
|
74
|
+
if $config.has_key? 'sites'
|
75
|
+
$sites = $config["sites"]
|
76
|
+
end
|
77
|
+
|
78
|
+
load_plugins
|
79
|
+
|
80
|
+
$drivers = {}
|
81
|
+
load_drivers
|
82
|
+
|
83
83
|
# check options
|
84
84
|
sub_commands = $sites.keys
|
85
85
|
global_opts = Trollop::options do
|
86
|
-
version "git-contest #{Git::Contest::VERSION} (c) 2013 Hiroyuki Sano"
|
86
|
+
version "git-contest #{Git::Contest::VERSION} (c) 2013-2014 Hiroyuki Sano"
|
87
87
|
banner get_banner
|
88
88
|
stop_on sub_commands
|
89
89
|
end
|
@@ -122,18 +122,21 @@ driver.on(
|
|
122
122
|
puts "@start: submit"
|
123
123
|
end
|
124
124
|
)
|
125
|
+
|
125
126
|
driver.on(
|
126
127
|
'before_login',
|
127
128
|
Proc.new do
|
128
129
|
puts "@submit: logging in..."
|
129
130
|
end
|
130
131
|
)
|
132
|
+
|
131
133
|
driver.on(
|
132
134
|
'after_login',
|
133
135
|
Proc.new do
|
134
136
|
puts "@submit: login ok"
|
135
137
|
end
|
136
138
|
)
|
139
|
+
|
137
140
|
driver.on(
|
138
141
|
'before_submit',
|
139
142
|
Proc.new do |submit_info|
|
@@ -141,24 +144,28 @@ driver.on(
|
|
141
144
|
puts "@submit: doing..."
|
142
145
|
end
|
143
146
|
)
|
147
|
+
|
144
148
|
driver.on(
|
145
149
|
'after_submit',
|
146
150
|
Proc.new do
|
147
151
|
puts "@submit: done"
|
148
152
|
end
|
149
153
|
)
|
154
|
+
|
150
155
|
driver.on(
|
151
156
|
'before_wait',
|
152
157
|
Proc.new do
|
153
158
|
print "@result: waiting..."
|
154
159
|
end
|
155
160
|
)
|
161
|
+
|
156
162
|
driver.on(
|
157
163
|
'retry',
|
158
164
|
Proc.new do
|
159
165
|
print "."
|
160
166
|
end
|
161
167
|
)
|
168
|
+
|
162
169
|
driver.on(
|
163
170
|
'after_wait',
|
164
171
|
Proc.new do |submission_info|
|
@@ -169,12 +176,14 @@ driver.on(
|
|
169
176
|
puts " %s: %s" % ["submission id", "#{submission_info[:submission_id]}"]
|
170
177
|
puts " %s: %s" % ["status", "#{submission_info[:status]}"]
|
171
178
|
puts ""
|
179
|
+
p submission_info
|
172
180
|
if git_contest_is_initialized
|
173
181
|
git_do "add #{get_git_add_target($config["submit_rules"]["add"] || ".")}"
|
174
182
|
git_do "commit --allow-empty -m '#{submission_info[:result]}'"
|
175
183
|
end
|
176
184
|
end
|
177
185
|
)
|
186
|
+
|
178
187
|
driver.on(
|
179
188
|
'finish',
|
180
189
|
Proc.new do
|
@@ -182,7 +191,15 @@ driver.on(
|
|
182
191
|
end
|
183
192
|
)
|
184
193
|
|
185
|
-
|
186
|
-
|
194
|
+
# global config
|
195
|
+
$config["submit_rules"] ||= {}
|
196
|
+
|
197
|
+
# set config
|
198
|
+
driver.config = $sites[site]
|
199
|
+
driver.config.merge! $config
|
200
|
+
|
201
|
+
# parse driver options
|
202
|
+
driver.options = driver.get_opts()
|
187
203
|
|
204
|
+
result = driver.submit()
|
188
205
|
|
data/git-contest.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.version = Git::Contest::VERSION
|
11
11
|
spec.authors = ["Hiroyuki Sano"]
|
12
12
|
spec.email = ["sh19910711@gmail.com"]
|
13
|
-
spec.description = %q{
|
14
|
-
spec.summary = %q{
|
13
|
+
spec.description = %q{The Git Extension for online judges (Codeforces, etc...)}
|
14
|
+
spec.summary = %q{The Git Extension for online judges (Codeforces, etc...)}
|
15
15
|
spec.homepage = "https://github.com/sh19910711/git-contest"
|
16
16
|
spec.license = "MIT"
|
17
17
|
|
data/lib/contest/driver.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# aizu_online_judge.rb
|
3
3
|
#
|
4
|
-
# Copyright (c) 2013 Hiroyuki Sano <sh19910711 at gmail.com>
|
4
|
+
# Copyright (c) 2013-2014 Hiroyuki Sano <sh19910711 at gmail.com>
|
5
5
|
# Licensed under the MIT-License.
|
6
6
|
#
|
7
7
|
|
@@ -57,29 +57,29 @@ module Contest
|
|
57
57
|
when "javascript"
|
58
58
|
return "JavaScript"
|
59
59
|
else
|
60
|
-
abort "unknown
|
60
|
+
abort "unknown language"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
def submit_ext
|
64
|
+
def submit_ext
|
65
65
|
# start
|
66
66
|
trigger 'start'
|
67
|
-
problem_id = "%04d" % options[:problem_id]
|
67
|
+
problem_id = "%04d" % @options[:problem_id]
|
68
68
|
|
69
69
|
@client = Mechanize.new {|agent|
|
70
70
|
agent.user_agent_alias = 'Windows IE 7'
|
71
71
|
}
|
72
72
|
|
73
73
|
# submit
|
74
|
-
trigger 'before_submit', options
|
74
|
+
trigger 'before_submit', @options
|
75
75
|
submit_page = @client.get "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0000"
|
76
76
|
submit_page.parser.encoding = "SHIFT_JIS"
|
77
77
|
res_page = submit_page.form_with(:action => '/onlinejudge/servlet/Submit') do |form|
|
78
|
-
form.userID = config["user"]
|
79
|
-
form.password = config["password"]
|
78
|
+
form.userID = @config["user"]
|
79
|
+
form.password = @config["password"]
|
80
80
|
form.problemNO = problem_id
|
81
|
-
form.language = options[:language]
|
82
|
-
form.sourceCode = File.read(
|
81
|
+
form.language = @options[:language]
|
82
|
+
form.sourceCode = File.read(@options[:source])
|
83
83
|
end.submit
|
84
84
|
trigger 'after_submit'
|
85
85
|
|
@@ -89,18 +89,18 @@ module Contest
|
|
89
89
|
submission_id = get_submission_id status_page.body
|
90
90
|
|
91
91
|
# wait result
|
92
|
-
status = get_status_wait config["user"], submission_id
|
92
|
+
status = get_status_wait @config["user"], submission_id
|
93
93
|
trigger(
|
94
94
|
'after_wait',
|
95
95
|
{
|
96
96
|
:submission_id => submission_id,
|
97
97
|
:status => status,
|
98
|
-
:result => get_commit_message(
|
98
|
+
:result => get_commit_message(status),
|
99
99
|
}
|
100
100
|
)
|
101
101
|
trigger 'finish'
|
102
102
|
|
103
|
-
|
103
|
+
get_commit_message(status)
|
104
104
|
end
|
105
105
|
|
106
106
|
def get_status_wait(user_id, submission_id)
|