Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 33 additions & 20 deletions tools/triage_py/triage_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
def sort_commit_hashes(commits):
git_cmd = 'git rev-list --abbrev-commit --topo-order --no-walk=sorted --reverse ' + ' '.join(commits)
p = subprocess.Popen(git_cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=git_repo, universal_newlines=True)
comm = p.communicate()
return comm[0].splitlines()
stdout, stderr = p.communicate()
if p.returncode != 0:
print('error: sorting commit hashes failed')
print(stderr)
sys.exit(1)
return stdout.splitlines()

verbose = args.verbose
do_compare = args.compare
Expand All @@ -45,27 +49,36 @@ def sort_commit_hashes(commits):
continue
versions.append(filename)

if len(versions):
try:
Version(versions[0])
use_hashes = False
versions.sort(key=Version)
except:
if verbose:
print("'{}' not a version - assuming commit hashes".format(versions[0]))
if not git_repo:
print('error: git repository argument required for commit hash sorting')
sys.exit(1)
if verbose:
print("using git repository '{}' to sort commit hashes".format(git_repo))
use_hashes = True
# if you use the folder from the bisect script that contains the repo as a folder - so remove it from the list
if versions.count('cppcheck'):
versions.remove('cppcheck')
versions = sort_commit_hashes(versions)
if not len(versions):
print("error: no versions found in '{}'".format(directory))
sys.exit(1)

if verbose:
print("found {} versions in '{}'".format(len(versions), directory))

try:
Version(versions[0])
use_hashes = False
versions.sort(key=Version)
except:
if verbose:
print("'{}' not a version - assuming commit hashes".format(versions[0]))
if not git_repo:
print('error: git repository argument required for commit hash sorting')
sys.exit(1)
if verbose:
print("using git repository '{}' to sort commit hashes".format(git_repo))
use_hashes = True
# if you use the folder from the bisect script that contains the repo as a folder - so remove it from the list
if versions.count('cppcheck'):
versions.remove('cppcheck')
len_in = len(versions)
versions = sort_commit_hashes(versions)
if len(versions) != len_in:
print('error: unexpected amount of versions after commit hash sorting')
sys.exit(1)

if verbose:
print("analyzing '{}'".format(input_file))

last_ec = None
Expand Down