@@ -1,3 +1,4 @@ | |||||
require 'io/console' | |||||
require 'nokogiri' | require 'nokogiri' | ||||
require 'open3' | require 'open3' | ||||
@@ -8,6 +9,21 @@ module KGrader::Backend | |||||
@fs = filesystem | @fs = filesystem | ||||
@course = course | @course = course | ||||
@config = config | @config = config | ||||
@password = nil | |||||
end | |||||
def prepare(semester, assignment) | |||||
return unless @config['verify'] | |||||
url = @config['verify'] % { | |||||
:semester => semester, | |||||
:assignment => assignment | |||||
} | |||||
status = run('list', '--non-interactive', url)[1] | |||||
if status.exited? && status.exitstatus != 0 | |||||
print "svn: password: " | |||||
@password = STDIN.noecho(&:gets).chomp | |||||
end | |||||
end | end | ||||
def revision(repo) | def revision(repo) | ||||
@@ -46,6 +62,10 @@ module KGrader::Backend | |||||
private | private | ||||
def run(*cmd) | def run(*cmd) | ||||
if @password | |||||
cmd.unshift '--password' | |||||
cmd.unshift @password | |||||
end | |||||
Open3.capture2e('svn', *cmd) | Open3.capture2e('svn', *cmd) | ||||
end | end | ||||
@@ -20,6 +20,7 @@ module KGrader | |||||
raise TaskError, "can't set a new due date without fetching" | raise TaskError, "can't set a new due date without fetching" | ||||
end | end | ||||
prepare | |||||
subtask 'setup' do |sub| | subtask 'setup' do |sub| | ||||
sub.create unless sub.exists? | sub.create unless sub.exists? | ||||
end | end | ||||
@@ -42,6 +43,7 @@ module KGrader | |||||
end | end | ||||
def commit | def commit | ||||
prepare | |||||
subtask 'commit', &:commit | subtask 'commit', &:commit | ||||
end | end | ||||
@@ -58,6 +60,10 @@ module KGrader | |||||
@student_len ||= @submissions.map { |sub| sub.student.length }.max | @student_len ||= @submissions.map { |sub| sub.student.length }.max | ||||
end | end | ||||
def prepare | |||||
@course.backend.prepare @semester, @assignment | |||||
end | |||||
def subtask(name) | def subtask(name) | ||||
progress = ProgressBar.create title: name, total: @submissions.size, | progress = ProgressBar.create title: name, total: @submissions.size, | ||||
throttle_rate: 0, format: '%t [%b>%i] %j%% %e ' | throttle_rate: 0, format: '%t [%b>%i] %j%% %e ' | ||||
@@ -1 +1 @@ | |||||
Subproject commit f9cb0aabbe48368ef7a8db6c43e7d81e71d2c4fa | |||||
Subproject commit 514bd96d25d797ceb17f166f508e3195afb795f1 |