On Sat, May 12, 2012 at 05:11:40PM +0200, Daniel Dehennin wrote:
> Package: git-buildpackage
> Version: 0.6.0~git20120419
> Severity: wishlist
> Tags: patch
> 
> Dear Maintainer,
> 
> During my work on #669171, I found useful to have a wrapper to "git
> merge-base".
> 
> I include the patch for review followed by a pull request.
> 
> Regards.
> 
> From e375b4f9fb4654159e1efcfae4a14a513234c683 Mon Sep 17 00:00:00 2001
> From: Daniel Dehennin <[email protected]>
> Date: Sat, 12 May 2012 17:00:24 +0200
> Subject: [PATCH] Add "git merge-base" wrapper.
> 
> * gbp/git/repository.py (GitRepository.get_merge_base): New method which
>   return SHA1 of a common ancestor between to commits.
> ---
>  gbp/git/repository.py |   15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/gbp/git/repository.py b/gbp/git/repository.py
> index 2cc5eda..a02d4ef 100644
> --- a/gbp/git/repository.py
> +++ b/gbp/git/repository.py
> @@ -299,6 +299,21 @@ class GitRepository(object):
>          remote += merge.replace("refs/heads","", 1)
>          return remote
>  
> +    def get_merge_base(self, commit1, commit2):
> +        """
> +        Get the common ancestor between two commits
> +        The commits can be SHA1 or names of branch or tag
> +
> +        @return: SHA1 of the common ancestor
> +        @rtype: C{str}
> +        """
> +        args = [commit1, commit2]
> +        sha1, stderr, ret = self._git_inout('merge-base', args)
> +        if not ret:
> +            return sha1.strip()
> +        else:
> +            raise GbpError("Failed to get common ancestor: %s" % stderr)
> +
>      def merge(self, commit, verbose=False, edit=False):
>          """
>          Merge changes from the named commit into the current branch

Looks great! Can you document commit1 and commit2 via epydoc too and add
a testcase to tests/test_GitRepository.py that tests the success as well
as the failure case? As a bonus construct the args argument via 

args = GitArgs(commit1, commit2)

for consistency with other recent code. I'd be happy to apply it then.
Cheers,
 -- Guido



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to