Skip to content

Commit

Permalink
Add first-parent option (True by default)
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Apr 8, 2022
1 parent 3fa82c9 commit ceab314
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 14 additions & 4 deletions bisect/bisect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -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' \
Expand Down Expand Up @@ -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__':
Expand Down
4 changes: 4 additions & 0 deletions bisect/example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ceab314

Please sign in to comment.