From 0088b2adc77b04fa024d15f49188eec46213e6a7 Mon Sep 17 00:00:00 2001 From: 0cool-f Date: Wed, 5 Jun 2019 14:19:35 +0200 Subject: [PATCH] Native and more stable way to get revision --- svn2github.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/svn2github.py b/svn2github.py index 97ddc0e..f1a90bd 100755 --- a/svn2github.py +++ b/svn2github.py @@ -19,14 +19,11 @@ class Svn2GithubException(Exception): def get_last_revision_from_svn(svn_url): - result = proc.run(["svn", "info", svn_url], check=True, stderr=DEVNULL, stdin=DEVNULL, stdout=PIPE) + result = proc.run(["svn", "info", svn_url, "--no-newline", "--show-item", "revision"], check=True, stderr=DEVNULL, stdin=DEVNULL, stdout=PIPE) - pattern = re.compile("^Revision: ([0-9]+)$".encode()) - - for line in result.stdout.split("\n".encode()): - m = pattern.match(line) - if m: - return int(m.group(1)) + rev = int (result.stdout.decode().strip()) + if rev: + return rev return Svn2GithubException("svn info {} output did not specify the current revision".format(svn_url))