in benchmark.py [0:0]
def _get_commits_topological(commits_sha_list,
repo,
flag_name,
fill_default=True):
"""Returns a list of commits, sorted by topological order.
e.g. for a commit history A -> B -> C -> D, commits_sha_list = [C, B]
Output: [B, C]
If the input commits_sha_list is empty, fetch the latest commit on branch
'master'
of the repo.
Args:
commits_sha_list: a list of string of commit SHA digest. Can be long or
short digest.
repo: the git.Repo instance of the repository.
flag_name: the flag that is supposed to specify commits_list.
fill_default: whether to fill in a default latest commit if none is
specified.
Returns:
A list of string of full SHA digests, sorted by topological commit order.
"""
if commits_sha_list:
long_commits_sha_set = set(
map(lambda x: _to_long_sha_digest(x, repo), commits_sha_list))
sorted_commit_list = []
for c in reversed(list(repo.iter_commits())):
if c.hexsha in long_commits_sha_set:
sorted_commit_list.append(c.hexsha)
if len(sorted_commit_list) != len(long_commits_sha_set):
raise ValueError(
"The following commits weren't found in the repo in branch master: %s."
% (long_commits_sha_set - set(sorted_commit_list)))
return sorted_commit_list
elif not fill_default:
# If we have some binary paths specified, we don't need to fill in a default
# commit.
return []
# If no commit specified: take the repo's latest commit.
latest_commit_sha = repo.commit().hexsha
logger.log('No %s specified, using the latest one: %s' %
(flag_name, latest_commit_sha))
return [latest_commit_sha]