Skip to content

Disable interactive git credential prompts on network operations - #9

Merged
bschellenberger2600 merged 1 commit into
mainfrom
fix/non-interactive-git-network
Jun 16, 2026
Merged

Disable interactive git credential prompts on network operations#9
bschellenberger2600 merged 1 commit into
mainfrom
fix/non-interactive-git-network

Conversation

@bschellenberger2600

@bschellenberger2600 bschellenberger2600 commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Add PrepareNetworkGit to set GIT_TERMINAL_PROMPT=0 on fetch/push subprocesses
  • Apply to FetchRemote, DetectConflict, PushBranch, and PushAllBranches
  • Add unit and HTTPS integration tests asserting fast non-interactive auth failure

Why

Batch CLIs (git-fire, git-rain) run parallel network git operations. When HTTPS remotes lack cached credentials, git prompts on the controlling TTY — bypassing captured stdout/stderr and interleaving Username for 'https://github.com': with structured output.

Related PRs

Merge order: this PR first → tag harness release → update git-fire #107 go.mod pin → merge siblings.

Test plan

  • go test -race -count=1 ./git/ -run 'TestNonInteractive|TestPrepareNetwork|TestFetchRemote_Unauthenticated' -v
  • CI green

Set GIT_TERMINAL_PROMPT=0 on fetch and push subprocesses so batch CLIs
never leak Username/password prompts to the TTY when credentials are missing.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds nonInteractiveGitEnv and PrepareNetworkGit to git/command.go to enforce GIT_TERMINAL_PROMPT=0 on git commands. Calls PrepareNetworkGit before executing fetch and push commands in DetectConflict, FetchRemote, PushBranch, and PushAllBranches in git/operations.go. Adds unit and integration tests in git/command_test.go.

Changes

Non-interactive Git environment

Layer / File(s) Summary
nonInteractiveGitEnv and PrepareNetworkGit implementation
git/command.go
Defines gitTerminalPromptKey constant, nonInteractiveGitEnv (filters existing GIT_TERMINAL_PROMPT entries from env and appends GIT_TERMINAL_PROMPT=0), and PrepareNetworkGit (sets cmd.Env via nonInteractiveGitEnv).
Callsite wiring and tests
git/operations.go, git/command_test.go
Adds PrepareNetworkGit(cmd) calls before CombinedOutput/Run in DetectConflict, FetchRemote, PushBranch, and PushAllBranches. Tests cover env override behavior, exec.Cmd mutation, unauthenticated HTTPS fetch failure, and a containsEnv helper.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hop hop, no prompt today,
The terminal won't get in the way!
GIT_TERMINAL_PROMPT=0 set just right,
Fetch and push fly through the night.
A rabbit's patch, clean and bright! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: disabling interactive git credential prompts during network operations, which aligns with the PR's primary purpose of addressing credential prompts in batch CLI operations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/non-interactive-git-network

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot check passed with no issues, but no Cursor[bot] PR review comment (BUGBOT_REVIEW) was posted, so I cannot approve without that signal. Maintainer review is recommended; no reviewers were assigned (sole human contributor is the PR author).

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@bschellenberger2600
bschellenberger2600 merged commit 34d1bcc into main Jun 16, 2026
8 checks passed
@bschellenberger2600
bschellenberger2600 deleted the fix/non-interactive-git-network branch June 16, 2026 03:44
bschellenberger2600 added a commit to git-fire/git-fire that referenced this pull request Jun 17, 2026
## Summary
- Bump `git-harness` to **v0.3.1** (released; sets
`GIT_TERMINAL_PROMPT=0` on fetch/push)
- Add executor integration tests for push-known and conflict-detection
fetch paths

## Why
`git-fire` delegates network git to `git-harness`. Without
`GIT_TERMINAL_PROMPT=0`, parallel pushes/fetches can prompt for HTTPS
credentials on the TTY when auth is missing.

## Related PRs
- git-harness (merged, v0.3.1):
git-fire/git-harness#9
- git-rain (sibling): git-fire/git-rain#16

## Test plan
- [x] `go test -race -count=1 ./internal/executor/ -run
'TestSummarizePushKnownRemote_Unauthenticated|TestDetectConflict_Unauthenticated'
-v`
- [x] `go.mod` pinned to `github.com/git-fire/git-harness v0.3.1`
- [ ] CI green (GoReleaser config validation failure is
pre-existing/unrelated)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Dependency bump and test-only executor coverage; release changes
affect install path (cask) but not runtime app logic.
> 
> **Overview**
> **Pins `git-harness` to v0.3.1** so fetch/push run with
`GIT_TERMINAL_PROMPT=0`, avoiding HTTPS credential prompts during
parallel emergency backups when auth is missing.
> 
> **Adds executor regression tests** (`network_git_test.go`) that hit
real HTTPS remotes without credentials and assert
`summarizePushKnownRemote` and `git.DetectConflict` fail quickly (within
15s), not hang on a TTY prompt.
> 
> **Switches macOS distribution from a Homebrew formula to a cask** in
`.goreleaser.stable.yaml` (binary + post-install `xattr` quarantine
strip on macOS). The release workflow gate now polls `homebrew-tap`’s
**cask** (`Casks/git-fire.rb`) instead of `Formula/git-fire.rb`.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
08901fa. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Ben Schellenberger <bschellenberger2600@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant