Skip to content

Add missing test coverage and harden open package#23

Merged
arbourd merged 1 commit into
mainfrom
harden
May 17, 2026
Merged

Add missing test coverage and harden open package#23
arbourd merged 1 commit into
mainfrom
harden

Conversation

@arbourd
Copy link
Copy Markdown
Owner

@arbourd arbourd commented May 17, 2026

  • Add TestGetURLErrors (not-a-git-repo, local remote, unsupported provider)
  • Add TestGetURLBareRepo covering the AbsoluteGitDir bare-repo fallback
  • Add TestConfigGetRegexp and TestLoadProvidersLocal for new gitw behaviour
  • Rename url → openURL in GetURL to fix net/url import shadowing
  • Add -- before URL in open/xdg-open to prevent flag injection
  • LoadProviders reads local git config before falling back to global
  • Move git config I/O into gitw.ConfigGetRegexp; open package no longer
    imports go-git-cmd-wrapper directly

@arbourd arbourd force-pushed the harden branch 2 times, most recently from 9d1db89 to 9b3c230 Compare May 17, 2026 13:51
@arbourd arbourd requested a review from Copilot May 17, 2026 13:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds missing test coverage for error paths and bare-repo handling in the open package, hardens the browser-launch commands against flag injection by inserting -- before the URL, eliminates a net/url import shadowing by renaming a local variable, and centralizes the git config --get-regexp invocation in the gitw package so that LoadProviders now picks up local repo configuration in addition to global.

Changes:

  • New tests: TestGetURLErrors, TestGetURLBareRepo, TestLoadProvidersLocal, TestConfigGetRegexp.
  • open: insert -- separator in open/xdg-open invocations and rename shadowing url variable to openURL.
  • gitw: new ConfigGetRegexp wrapper consumed by open.LoadProviders, dropping open's direct dependency on go-git-cmd-wrapper.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
open/provider.go Replaces direct git config call with gitw.ConfigGetRegexp; drops dependency on go-git-cmd-wrapper.
open/provider_test.go Adds TestLoadProvidersLocal covering local-config provider discovery.
open/open.go Adds -- separator to open/xdg-open and renames url to openURL to fix shadowing.
open/open_test.go Adds error-path and bare-repo coverage for GetURL.
gitw/gitw.go Adds ConfigGetRegexp wrapper; imports config subpackage.
gitw/gitw_test.go Adds TestConfigGetRegexp exercising local config retrieval.
AGENTS.md Updates docs to reflect new wrapper, tests, and local-config precedence.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread gitw/gitw.go Outdated
- Add TestGetURLErrors (not-a-git-repo, local remote, unsupported provider)
- Add TestGetURLBareRepo covering the AbsoluteGitDir bare-repo fallback
- Add TestConfigGetRegexp and TestLoadProvidersLocal for new gitw behaviour
- Rename url → openURL in GetURL to fix net/url import shadowing
- Add -- before URL in open/xdg-open to prevent flag injection
- LoadProviders reads local git config before falling back to global
- Move git config I/O into gitw.ConfigGetRegexp; open package no longer
  imports go-git-cmd-wrapper directly
@arbourd arbourd merged commit 1a94bec into main May 17, 2026
4 checks passed
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