From 0a583ebc99a225355e32c7164e57eb3463eacac3 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 21 Apr 2016 23:52:22 -0500 Subject: [PATCH] Store SVN password in memory. --- lib/kgrader/backend/svn.rb | 20 ++++++++++++++++++++ lib/kgrader/task.rb | 6 ++++++ spec/cs241h | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/kgrader/backend/svn.rb b/lib/kgrader/backend/svn.rb index 4af767f..2701eb8 100644 --- a/lib/kgrader/backend/svn.rb +++ b/lib/kgrader/backend/svn.rb @@ -1,3 +1,4 @@ +require 'io/console' require 'nokogiri' require 'open3' @@ -8,6 +9,21 @@ module KGrader::Backend @fs = filesystem @course = course @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 def revision(repo) @@ -46,6 +62,10 @@ module KGrader::Backend private def run(*cmd) + if @password + cmd.unshift '--password' + cmd.unshift @password + end Open3.capture2e('svn', *cmd) end diff --git a/lib/kgrader/task.rb b/lib/kgrader/task.rb index 4ebf7e0..fc69a1d 100644 --- a/lib/kgrader/task.rb +++ b/lib/kgrader/task.rb @@ -20,6 +20,7 @@ module KGrader raise TaskError, "can't set a new due date without fetching" end + prepare subtask 'setup' do |sub| sub.create unless sub.exists? end @@ -42,6 +43,7 @@ module KGrader end def commit + prepare subtask 'commit', &:commit end @@ -58,6 +60,10 @@ module KGrader @student_len ||= @submissions.map { |sub| sub.student.length }.max end + def prepare + @course.backend.prepare @semester, @assignment + end + def subtask(name) progress = ProgressBar.create title: name, total: @submissions.size, throttle_rate: 0, format: '%t [%b>%i] %j%% %e ' diff --git a/spec/cs241h b/spec/cs241h index f9cb0aa..514bd96 160000 --- a/spec/cs241h +++ b/spec/cs241h @@ -1 +1 @@ -Subproject commit f9cb0aabbe48368ef7a8db6c43e7d81e71d2c4fa +Subproject commit 514bd96d25d797ceb17f166f508e3195afb795f1