def get_commits(self, since_sha=None): """Returns a list of Commit objects. Args: since_sha - (optional) A sha to search from """ assert self.tempdir cmd = ['git', 'log', '--first-parent', '--reverse', COMMIT_FORMAT] if since_sha: commits = [self.get_commit(since_sha)] cmd.append('{0}..HEAD'.format(since_sha)) else: commits = [] cmd.append('HEAD') output = cmd_output(*cmd, cwd=self.tempdir) for sha, date in chunk_iter(output.splitlines(), 2): commits.append(Commit(sha, int(date))) return commits
def get_commits(self, since_sha: Optional[str] = None) -> List[Commit]: """Returns a list of Commit objects. Args: since_sha - (optional) A sha to search from """ assert self.tempdir cmd = ['git', 'log', '--first-parent', '--reverse', COMMIT_FORMAT] if since_sha: commits = [self.get_commit(since_sha)] cmd.append(f'{since_sha}..HEAD') else: commits = [] cmd.append('HEAD') output = cmd_output(*cmd, cwd=self.tempdir) for sha, date in chunk_iter(output.splitlines(), 2): commits.append(Commit(sha, int(date))) return commits
def test_chunk_iter(input_list, n, expected_output): output = list(chunk_iter(input_list, n)) assert output == expected_output