Skip to content

Remove git-urls dependency by inlining URL parsing#734

Closed
plural-copilot[bot] wants to merge 1 commit into
mainfrom
agent/remove-git-urls-dependency-1777780149828
Closed

Remove git-urls dependency by inlining URL parsing#734
plural-copilot[bot] wants to merge 1 commit into
mainfrom
agent/remove-git-urls-dependency-1777780149828

Conversation

@plural-copilot

@plural-copilot plural-copilot Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR removes the github.com/whilp/git-urls dependency from the codebase by inlining the minimal URL parsing functionality that was actually being used. The git-urls package was only used in two places in pkg/up/context.go:

  1. identifier() function: Extracting the repository path from HTTP(S) URLs
  2. getGitUsername() function: Extracting username from various git URL formats (SCP-style, SSH, HTTPS)

Both use cases have been replaced with Go's standard library net/url package along with simple string manipulation, maintaining 100% compatibility with the existing behavior.

Changes

  • pkg/up/context.go:

    • Removed import of github.com/whilp/git-urls
    • Added import of net/url from standard library
    • Updated identifier() to use url.Parse() instead of giturls.Parse()
    • Updated getGitUsername() to use url.Parse() with proper handling for different URL formats
  • go.mod: Removed github.com/whilp/git-urls v1.0.0 dependency

  • go.sum: Removed associated checksums

Validation

  • All existing unit tests in pkg/up/context_test.go cover the modified functions
  • Test validation confirms correct behavior for:
    • SCP-style URLs: git@github.com:user/repo.git
    • SSH URLs: ssh://git@github.com/user/repo.git
    • HTTPS URLs with credentials: https://oauth2@github.com/user/repo.git
    • HTTPS URLs without credentials: https://github.com/user/repo.git
    • Various edge cases (nested paths, different hosts, etc.)

Benefits

  • ✅ Reduces external dependency footprint
  • ✅ Eliminates potential security vulnerability vector
  • ✅ Uses only Go standard library (more maintainable)
  • ✅ Maintains full backward compatibility
  • ✅ No functional changes to end users

Related Work

This is a separate effort from PR #733 which addressed go-git vulnerabilities. This PR specifically targets the git-urls dependency removal as requested.

This change eliminates the external git-urls dependency by replacing its usage with Go's standard library net/url package. The git-urls package was only used for two simple URL parsing operations:

1. Extracting the path component from HTTP(S) git URLs
2. Extracting the username from various git URL formats (SCP-style, SSH, HTTPS)

Changes:
- Replaced giturls.Parse() calls with url.Parse() from standard library
- Updated getGitUsername() to handle URL parsing with proper fallback logic
- Removed github.com/whilp/git-urls from go.mod and go.sum
- All existing tests pass with the new implementation

This reduces the dependency footprint and eliminates a potential security vulnerability vector.

@plural-copilot plural-copilot Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This PR was generated by the claude Plural Agent Runtime. Here's some useful information you might want to know to evaluate the ai's perfomance:

Name Details
💬 Prompt Determine whether the requested git-urls removal work in pluralsh/plural-cli has already been completed, and if not, complete it by creating a PR....
🔗 Run history View run history

@michaeljguarino michaeljguarino added the enhancement New feature or request label May 3, 2026
@michaeljguarino michaeljguarino deleted the agent/remove-git-urls-dependency-1777780149828 branch May 3, 2026 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant