<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def list_commit(self, repo_name, to_commit=None, from_commit=None, number=0):
 """ Gets a list of CommitInfo objects. Params: * repo_name: If only `repo_name` is given, all commits in the repo are returned. * to_commit: Optional. Only the ancestors of `to`, including `to` itself, are considered. * from_commit: Optional. Only the descendants of `from`, including `from` itself, are considered. * number: Optional. Determines how many commits are returned. If `number` is 0, all commits that match the aforementioned criteria are returned. """

        req = proto.ListCommitRequest(repo=proto.Repo(name=repo_name), number=number)
        if to_commit is not None:
            req.to.CopyFrom(commit_from(to_commit))
        if from_commit is not None:
            getattr(req, 'from').CopyFrom(commit_from(from_commit))
        res = self.stub.ListCommit(req, metadata=self.metadata)
        if hasattr(res, 'commit_info'):
            return res.commit_info
        return []