瀏覽代碼

Store SVN password in memory.

master
Ben Kurtovic 8 年之前
父節點
當前提交
0a583ebc99
共有 3 個檔案被更改,包括 27 行新增1 行删除
  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 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存