diff --git a/bisect/bisect.py b/bisect/bisect.py index e4ac19242f..68e5f62d70 100755 --- a/bisect/bisect.py +++ b/bisect/bisect.py @@ -6,7 +6,7 @@ import subprocess -def bisect(good, bad, e3sm_path, load_script, config_file): +def bisect(good, bad, e3sm_path, load_script, config_file, first_parent): """ The driver function for calling ``git bisect`` to find the first "bad" commit between a known "good" and "bad" commit. @@ -31,8 +31,12 @@ def bisect(good, bad, e3sm_path, load_script, config_file): build the MPAS component to test. config_file : str The relative or absolute path to a config file containing config - options similar to ``bisect/exanmple.cfg`` that control the bisection + options similar to ``bisect/example.cfg`` that control the bisection process. + first_parent : bool + Whether to only follow the first parent for merge commits. This is + typically desirable because there may be broken commits within a branch + that are fixed by the time the branch is merged. """ e3sm_path = os.path.abspath(e3sm_path) @@ -41,9 +45,14 @@ def bisect(good, bad, e3sm_path, load_script, config_file): cwd = os.getcwd() + if first_parent: + flags = '--first-parent' + else: + flags = '' + commands = f'source {load_script}; ' \ f'cd {e3sm_path}; ' \ - f'git bisect start; ' \ + f'git bisect start {flags}; ' \ f'git bisect good {good}; ' \ f'git bisect bad {bad}; ' \ f'git bisect run {cwd}/bisect/bisect_step.py' \ @@ -74,7 +83,8 @@ def main(): bisect(good=section['good'], bad=section['bad'], e3sm_path=section['e3sm_path'], load_script=section['load_script'], - config_file=args.config_file) + config_file=args.config_file, + first_parent=section.getboolean('first_parent')) if __name__ == '__main__': diff --git a/bisect/example.cfg b/bisect/example.cfg index b91e1f041b..aee31b99ab 100644 --- a/bisect/example.cfg +++ b/bisect/example.cfg @@ -6,6 +6,10 @@ good = 44814ae # The hash or tag of a bad commit where the tests fail bad = 7b87d1f +# whether to only follow the first parent for merge commits. This is typically +# desirable because there may be broken commits within a branch that are fixed +# by the time the branch is merged. +first_parent = True # the absolute or relative path to the base of the E3SM branch you want to build e3sm_path = E3SM-Project # the absolute or relative path to the MPAS model directory you want to build