def commits()

in asfyaml/dataobjects.py [0:0]


    def commits(self, num=None, reverse=False):
        """Lists all commits in this ref update as Commit objects"""
        # Deleted refs have no commits.
        if self.deleted:
            return
        # Only report commits that aren't reachable from any other branch
        refs = []
        args = ["for-each-ref", "--format=%(refname)"]

        for r in gitcmd(*args).splitlines():
            if r.strip() == self.name:
                continue
            if r.strip().startswith("refs/heads/"):
                refs.append("^%s" % r.strip())
        args = ["rev-list"]
        if num is not None:
            args += ["-n", str(num)]
        if reverse:
            args.append("--reverse")
        if self.created:
            args += refs
            args.append(self.newsha)
        else:
            args.append("%s..%s" % (self.oldsha, self.newsha))
        for line in gitcmd(*args).splitlines():
            sha = line.strip()
            yield Commit(self, sha)