Browse Source

Store SVN password in memory.

master
Ben Kurtovic 8 years ago
parent
commit
0a583ebc99
3 changed files with 27 additions and 1 deletions
  1. +20
    -0
      lib/kgrader/backend/svn.rb
  2. +6
    -0
      lib/kgrader/task.rb
  3. +1
    -1
      spec/cs241h

+ 20
- 0
lib/kgrader/backend/svn.rb View File

@@ -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



+ 6
- 0
lib/kgrader/task.rb View File

@@ -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 '


+ 1
- 1
spec/cs241h

@@ -1 +1 @@
Subproject commit f9cb0aabbe48368ef7a8db6c43e7d81e71d2c4fa
Subproject commit 514bd96d25d797ceb17f166f508e3195afb795f1

Loading…
Cancel
Save