Add --commit flag to commit dirty files without confirmation

This commit is contained in:
Paul Gauthier 2023-05-08 17:04:49 -07:00
parent f9569e7645
commit a096c6e5e4

View file

@ -473,10 +473,12 @@ class Coder:
if not res: if not res:
self.console.print("[red]Skipped commmit.") self.console.print("[red]Skipped commmit.")
return return
else:
repo.git.add(*relative_dirty_fnames) repo.git.add(*relative_dirty_fnames)
repo.git.commit("-m", commit_message) commit_result = repo.git.commit("-m", commit_message, "--no-verify")
self.console.print("[green]Commit successful.") commit_hash = repo.head.commit.hexsha[:7]
self.console.print(f"[green]Commit successful. Short hash: {commit_hash}")
return commit_hash
def main(): def main():
@ -505,7 +507,7 @@ def main():
parser.add_argument( parser.add_argument(
"--commit", "--commit",
action="store_true", action="store_true",
help="Commit dirty changes to the files", help="Commit dirty files without confirmation",
) )
args = parser.parse_args() args = parser.parse_args()
@ -515,9 +517,7 @@ def main():
pretty = args.pretty pretty = args.pretty
coder = Coder(use_gpt_4, fnames, pretty) coder = Coder(use_gpt_4, fnames, pretty)
if args.commit: coder.commit("", ask=args.commit)
coder.commit("", ask=True)
return
if args.apply: if args.apply:
with open(args.apply, "r") as f: with open(args.apply, "r") as f: