From b543f6731eea308e56fdf9f3d72ed3a907653be8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Guido=20G=C3=BCnther?= Date: Sat, 24 Oct 2009 19:47:09 +0200 Subject: [PATCH] add GitRepository.is_fast_forward() --- gbp/git.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gbp/git.py b/gbp/git.py index fea10f9..5bd7fee 100644 --- a/gbp/git.py +++ b/gbp/git.py @@ -83,6 +83,15 @@ class GitRepository(object): remote += merge.replace("refs/heads","", 1) return remote + def is_fast_forward(self, from_branch, to_branch): + """check if an update from from_branch to to_branch would be a fast forward""" + out = self.__git_getoutput('rev-list', ["--left-right", + "%s...%s" % (from_branch, to_branch)])[0] + for line in out: + if line.startswith("<"): + return False + return True + def set_branch(self, branch): """switch to branch 'branch'""" self.__check_path() -- 2.7.4