From 69eac74e64c180900f4aaf47e96894880aa350d7 Mon Sep 17 00:00:00 2001 From: Sebb Date: Sat, 2 Mar 2024 13:45:39 +0000 Subject: [PATCH] method for parsing svn log listing --- lib/whimsy/asf/svn.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb index 51cb248c3a..fd80a81715 100644 --- a/lib/whimsy/asf/svn.rb +++ b/lib/whimsy/asf/svn.rb @@ -435,6 +435,23 @@ def self.svn!(command, path, options = {}) return out, err end + # get list of commmits from initial to current, and parses the output + # Returns: [out, err], where: + # out = array of entries, each of which is an array of [commitid, committer, datestamp] + # err = error message (in which case out is nil) + def self.svn_commits(path, before, after, env=nil) + out, err = ASF::SVN.svn('log', path, {env: env, quiet: true, revision: "#{before}:#{after}"}) + # extract lines starting with r1234, and split into fields + return out&.scan(%r{^r\d+ .*})&.map {|k| k.split(' | ')}, err + end + + # as for self.svn_commits, but failure raises an error + def self.svn_commits!(path, before, after, env=nil) + out, err = self.svn_commits(path, before, after, env) + raise Exception.new("SVN command failed: #{err}") if out.nil? + return out, err + end + # low level SVN command for use in Wunderbar context (_json, _text etc) # params: # command - info, list etc