in bowler/tool.py [0:0]
def process_hunks(self, filename: Filename, hunks: List[Hunk]) -> None:
auto_yes = False
result = ""
accepted_hunks = ""
for hunk in hunks:
if self.hunk_processor(filename, hunk) is False:
continue
if not self.silent:
for line in hunk:
if line.startswith("---"):
click.secho(line, fg="red", bold=True)
elif line.startswith("+++"):
click.secho(line, fg="green", bold=True)
elif line.startswith("-"):
click.secho(line, fg="red")
elif line.startswith("+"):
click.secho(line, fg="green")
else:
click.echo(line)
if self.interactive:
if auto_yes:
click.echo(f"Applying remaining hunks to {filename}")
result = "y"
else:
result = prompt_user("Apply this hunk", "ynqad", "n")
self.log_debug(f"result = {result}")
if result == "q":
self.apply_hunks(accepted_hunks, filename)
raise BowlerQuit()
elif result == "d":
self.apply_hunks(accepted_hunks, filename)
return # skip all remaining hunks
elif result == "n":
continue
elif result == "a":
auto_yes = True
result = "y"
elif result != "y":
raise ValueError("unknown response")
if result == "y" or self.write:
accepted_hunks += "\n".join(hunk[2:]) + "\n"
self.apply_hunks(accepted_hunks, filename)