-
Notifications
You must be signed in to change notification settings - Fork 134
Capture clone subprocess output to match rest of file #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,12 +111,13 @@ def shallow_clone( | |
| if _GIT_EXECUTABLE is None: | ||
| raise RuntimeError("git not on PATH; cannot clone") | ||
| try: | ||
| # nosec B603 — argv is statically constructed ("clone --progress | ||
| # --depth 1 --"); effective_url comes from the agent's own URL | ||
| # nosec B603 — argv is statically constructed ("clone --depth 1 | ||
| # --"); effective_url comes from the agent's own URL | ||
| # validation + token injection; target is a Path the agent | ||
| # owns. Absolute git path resolved at module load (kills B607). | ||
| result = subprocess.run( # nosec B603 | ||
| [_GIT_EXECUTABLE, "clone", "--progress", "--depth", "1", "--", effective_url, str(target)], | ||
| [_GIT_EXECUTABLE, "clone", "--depth", "1", "--", effective_url, str(target)], | ||
| capture_output=True, | ||
| text=True, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking / FYI. Attaching pipes slightly weakens this timeout. On Low likelihood, and I wouldn't hold the PR for it — but this timeout exists specifically as a hang guard, so it's worth knowing the failure mode changed. If you want to close it properly, |
||
| timeout=timeout_seconds, | ||
| env=env, | ||
|
|
@@ -132,8 +133,8 @@ def shallow_clone( | |
| if target.exists(): | ||
| shutil.rmtree(target, ignore_errors=True) | ||
| raise RuntimeError( | ||
| f"git clone failed (exit {result.returncode}) for {redact(repo_url)}; " | ||
| "see git output above" | ||
| f"git clone failed (exit {result.returncode}) for {redact(repo_url)}: " | ||
| f"{redact(result.stderr.strip())}" | ||
| ) | ||
|
|
||
| # Strip the token from the remote URL stored in .git/config. Without | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking.
capture_output=Trueroutes git's stderr intoresult.stderr, but nothing ever reads it — and the failure branch at lines 131-137 still tells the operator to "see git output above", which after this change points at nothing.GitHub won't let me anchor a comment on line 131 (outside the diff), so the suggested edit for that branch:
This mirrors the
fetch(line 266-270) andcheckout(line 283-287) handlers exactly, which is the consistency this PR is going for.redact()is mandatory here, not stylistic — same reasoning as thescrubwarning at line 163. git will happily print the tokenized remote URL in some failure messages, and this exception propagates up to__main__.py:902where it lands in operator-visible output.Please also add the
stderrtest coverage described in the review body —_FakeCompletedcurrently pinsstderr = "", so neither the diagnostics loss nor a redaction miss would fail CI today.