From da5e849b5be29e887f106f89eaa75811e46da7ad Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Wed, 6 Apr 2016 15:08:07 -0500 Subject: [PATCH] SVN revision, update to rev --- README.md | 2 +- lib/kgrader/backend/svn.rb | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2873c02..70f213b 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ version of Ruby. Install dependencies with gem: - gem install ruby-progressbar + gem install nokogiri ruby-progressbar Download kgrader over git: diff --git a/lib/kgrader/backend/svn.rb b/lib/kgrader/backend/svn.rb index db175d9..7abd407 100644 --- a/lib/kgrader/backend/svn.rb +++ b/lib/kgrader/backend/svn.rb @@ -1,3 +1,4 @@ +require 'nokogiri' require 'open3' module KGrader::Backend @@ -10,8 +11,8 @@ module KGrader::Backend end def revision(repo) - # TODO - -1 + xml = Nokogiri::XML run('log', '--xml', '-l', '1', repo).first + xml.css('logentry').attr('revision').value.to_i end def clone(repo, semester, assignment, student) @@ -19,8 +20,10 @@ module KGrader::Backend run 'checkout', '--ignore-externals', url, repo end - def update(repo) - run 'update', '--ignore-externals', '--accept', 'tf', repo + def update(repo, revision = nil) + args = 'update', '--ignore-externals', '--accept', 'tf' + args.push "-r#{revision}" unless revision.nil? + run *args, repo end private