+5
-5
@@ -11,15 +11,15 @@ owner = os.environ.get("REPO_OWNER", os.environ.get("GITHUB_REPOSITORY_OWNER"))
|
||||
repo = os.environ.get("REPO_NAME", os.environ.get("GITHUB_REPOSITORY"))
|
||||
pr_index = os.environ["PR_INDEX"]
|
||||
api_url = os.environ.get("API_URL", os.environ.get("GITHUB_API_URL"))
|
||||
diff_text = os.environ.get("DIFF") # optional
|
||||
content_text = os.environ.get("CONTENT") # optional large text input
|
||||
comment_template = os.environ.get("COMMENT_TEMPLATE", "Auto-comment: changed line -> {line}")
|
||||
|
||||
if not token or not pr_index:
|
||||
print("TOKEN and PR_INDEX are required.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# If diff_text is empty, just post a general PR comment
|
||||
if not diff_text:
|
||||
# If no content provided, just post a general PR comment
|
||||
if not content_text:
|
||||
body = comment_template.replace("{line}", "").replace("{lines}", "")
|
||||
if platform == "github":
|
||||
url = f"https://api.github.com/repos/{owner}/{repo}/issues/{pr_index}/comments"
|
||||
@@ -44,12 +44,12 @@ if not diff_text:
|
||||
print(resp.text, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# --- If diff_text exists, parse diff normally ---
|
||||
# --- If content_text exists, parse it for added lines like a diff ---
|
||||
diff_files = {}
|
||||
current_file = None
|
||||
new_line_num = None
|
||||
|
||||
for line in diff_text.splitlines():
|
||||
for line in content_text.splitlines():
|
||||
if line.startswith("+++ b/"):
|
||||
current_file = line[6:].strip()
|
||||
diff_files[current_file] = []
|
||||
|
||||
Reference in New Issue
Block a user