Skip to content

SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]

Fix: Insufficient quoting of git commit message (#646)

Kilian Lieret487f23f5f289
diff --git a/sweagent/environment/swe_env.py b/sweagent/environment/swe_env.py
index 31ce7fa4..06e8dd14 100644
--- a/sweagent/environment/swe_env.py
+++ b/sweagent/environment/swe_env.py
@@ -7,6 +7,7 @@ import logging
import os
import random
import re
+import shlex
import subprocess
import time
import traceback
@@ -1166,8 +1167,12 @@ class SWEEnv(gym.Env):
timeout_duration=10,
)
dry_run_flag = "--allow-empty" if _dry_run else ""
+ commit_msg = [
+ shlex.quote("Fix: {issue.title}"),
+ shlex.quote("Closes #{issue.number}"),
+ ]
self.communicate_with_handling(
- input=f"git commit -m 'Fix: {issue.title}' -m 'Closes #{issue.number}' {dry_run_flag}",
+ input=f"git commit -m {commit_msg[0]} -m {commit_msg[1]} {dry_run_flag}",
error_msg="Failed to commit changes",
timeout_duration=10,
)