Skip to content

Harden GoFetch: bug fixes, new features, full Windows/macOS/Linux support - #2

Merged
ciao22king merged 1 commit into
mainfrom
gofetch-hardening-cross-platform
Oct 2, 2026
Merged

ciao22king merged 1 commit into
mainfrom
gofetch-hardening-cross-platform

Conversation

@ciao22king

Copy link
Copy Markdown
Owner

What this does

This PR fixes the bugs found in the current code and turns GoFetch into one complete, cross-platform version that works the same on Windows, macOS and Linux.

This PR was created by an AI agent (OpenHands) on behalf of the repository owner.

Bug fixes

  • Clone target depended on the working directory. destinationPath now expands ~ and returns an absolute path, so git clone always writes where the UI says it will.
  • Unsafe folder names. Repository names are now sanitized for every platform: Windows-forbidden characters (\ / : * ? " < > |), trailing dots/spaces and reserved device names (CON, COM1, …). URLs containing spaces are rejected early.
  • Cloning into an existing folder now shows an explicit overwrite confirmation instead of git's raw "not an empty directory" error.
  • History corruption on crash. history.json is now written atomically (temp file + rename, with a Windows fallback) instead of a direct overwrite.
  • Tab completion never advanced. nextSuggestion used a value receiver, so the suggestion index was reset on every call. Fixed with a pointer receiver.
  • q while typing quit the app. Typing q in the URL or path field no longer quits; quit is now Ctrl+C/q only where it is not a text field.
  • Windows home expansion now also understands ~\.
  • Friendlier clone errors for repository-not-found, authentication, DNS/network failures and timeouts, while keeping the raw output available.

New features

  • Self-hosted / generic Git hosts are accepted alongside GitHub and GitLab.
  • ssh:// URLs, www. stripping and trailing-slash handling.
  • Cancellable clones (Esc) that clean up the partial directory.
  • History search (/ or Ctrl+L), entry removal (Ctrl+D) and relative timestamps.
  • Ctrl+O opens the selected folder, Ctrl+Y copies its path.
  • Tab cycles through recent destination folders.
  • Broader automatic build detection: Maven, Gradle, Make, Python, and npm/yarn/pnpm (in addition to Go, Rust, Node).
  • --no-build flag for untrusted repositories.
  • install.ps1 for Windows; install.sh now installs a stable gofetch name and supports bash, zsh and fish.
  • GitHub Actions CI across Linux, macOS and Windows, plus a cross-compile job.

Verification

  • gofmt clean, go vet ./... clean.
  • go test -race -count=1 ./... passes (URL parsing, sanitization, history persistence, build detection, the TUI state machine, and a real end-to-end git clone).
  • Cross-compiles for windows/amd64, darwin/amd64, darwin/arm64, linux/amd64, linux/arm64, linux/386.
  • install.sh was executed end-to-end and produced a working gofetch 0.4.0.

Version bumped to 0.4.0; README rewritten to document everything.

@ciao22king can click here to continue refining the PR

Fix a set of correctness and portability bugs and add features while
keeping a single, complete, cross-platform version.

Bug fixes:
- destinationPath now expands ~ and returns an absolute path, so the
  clone target can never depend on the process working directory.
- Sanitize repository names for every platform (Windows-forbidden chars,
  trailing dots/spaces, reserved device names like CON/COM1) and reject
  URLs containing spaces.
- Refuse to clone into a non-empty folder and offer an explicit
  overwrite confirmation instead of failing with git's raw error.
- History is written atomically (temp file + rename, Windows fallback)
  so a crash can no longer truncate history.json.
- nextSuggestion used a value receiver and never advanced: tab
  completion now really cycles through recent folders.
- Typing "q" while entering a URL or path no longer quits the app.
- Cross-platform home expansion also understands "~\" on Windows.
- Friendlier, actionable clone errors (not found, auth, DNS, network).

New:
- Self-hosted / generic Git hosts accepted alongside GitHub and GitLab.
- ssh:// URLs, www. stripping and trailing-slash handling.
- Cancellable clones (Esc) that clean up the partial directory.
- History search (/, ctrl+l), entry removal (ctrl+d), relative timestamps.
- ctrl+o opens the selected folder, ctrl+y copies its path.
- Tab completion for the destination directory.
- Broader build detection: Maven, Gradle, Make, Python, and npm/yarn/pnpm.
- --no-build flag for untrusted repositories.
- install.ps1 for Windows; install.sh now installs a stable "gofetch"
  name and supports bash/zsh/fish.
- GitHub Actions CI across Linux, macOS and Windows plus cross-compile.
- Much larger test suite, including a real end-to-end git clone.

Version bumped to 0.4.0. README rewritten to document all of it.

Co-authored-by: openhands <openhands@all-hands.dev>
@ciao22king
ciao22king marked this pull request as ready for review October 2, 2026 15:59
@ciao22king
ciao22king merged commit cfcd826 into main Oct 2, 2026
4 checks passed
@ciao22king
ciao22king deleted the gofetch-hardening-cross-platform branch October 2, 2026 16:22
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.

2 participants