From: Lin Yang Date: Thu, 30 Aug 2012 08:17:56 +0000 (+0800) Subject: Support check whether commit exist in remote branch X-Git-Tag: 0.9~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d549024ced8a6d7f40b8144999574130beadef28;p=services%2Fjenkins-scripts.git Support check whether commit exist in remote branch --- diff --git a/common/git.py b/common/git.py index f760875..ec67182 100644 --- a/common/git.py +++ b/common/git.py @@ -401,16 +401,19 @@ class Git: def branch_contains(self, cmitid): with Workdir(self.path): - ret, outs = self._exec_git('branch --contains', [cmitid]) + ret, outs = self._exec_git('branch -a --contains', [cmitid]) if not ret: - branchs = [] + branches = [] for br in outs.splitlines(): - if br.startswith('* '): - branchs.append(br[len('* '):]) - else: - branchs.append(br) - print 'git branch contains %s' % branchs - return branchs + if br.find('remotes/origin/HEAD ->') != -1: + continue + br = br.strip().lstrip('* ') + if br.startswith('remotes/origin/'): + br = br[len('remotes/origin/'):] + if br not in branches: + branches.append(br) + print 'git branch contains %s' % branches + return branches else: return None