diff options
| author | Sandy Carter <sandy.carter@savoirfairelinux.com> | 2015-07-21 11:02:24 -0400 | 
|---|---|---|
| committer | Sandy Carter <sandy.carter@savoirfairelinux.com> | 2015-07-21 11:02:24 -0400 | 
| commit | 65c07d64a7b1dc85c41083c60a8082b3705154c3 (patch) | |
| tree | c4ef1f3d52a35a289c6e920dbcf79666cda2952c /git/repo/base.py | |
| parent | f360ecd7b2de173106c08238ec60db38ec03ee9b (diff) | |
| download | gitpython-65c07d64a7b1dc85c41083c60a8082b3705154c3.tar.gz | |
Implement is_ancestor
Wrap `git merge-base --is-ancestor` into its own function because it acts
as a boolean check unlike base `git merge-base call`
Diffstat (limited to 'git/repo/base.py')
| -rw-r--r-- | git/repo/base.py | 15 | 
1 files changed, 15 insertions, 0 deletions
diff --git a/git/repo/base.py b/git/repo/base.py index b0411235..16fb58e5 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -504,6 +504,21 @@ class Repo(object):          return res +    def is_ancestor(self, ancestor_rev, rev): +        """Check if a commit  is an ancestor of another + +        :param ancestor_rev: Rev which should be an ancestor +        :param rev: Rev to test against ancestor_rev +        :return: ``True``, ancestor_rev is an accestor to rev. +        """ +        try: +            self.git.merge_base(ancestor_rev, rev, is_ancestor=True) +        except GitCommandError as err: +            if err.status == 1: +                return False +            raise +        return True +      def _get_daemon_export(self):          filename = join(self.git_dir, self.DAEMON_EXPORT_FILE)          return os.path.exists(filename)  | 
