Skip to content

feat: integrate gh CLI for protocol config and token auto-discovery#15

Merged
stefreak merged 5 commits intomainfrom
copilot/fix-clone-url-assumptions
Nov 29, 2025
Merged

feat: integrate gh CLI for protocol config and token auto-discovery#15
stefreak merged 5 commits intomainfrom
copilot/fix-clone-url-assumptions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 29, 2025

✅ Implementation Complete

Summary

Successfully integrated GitHub CLI (gh) to eliminate hardcoded assumptions about user's GitHub configuration.

Key Changes

  • Create a new gh.rs module for GitHub CLI integration
  • Implement function to read git_protocol from gh config
  • Implement function to get GitHub token from gh auth token
  • Make github_token optional in CLI arguments
  • Update git clone URL generation to use configured protocol
  • Add comprehensive tests for gh CLI integration (5 unit + 1 integration)
  • Test that everything works without gh installed
  • Run linter and all tests (19 tests passing, 0 warnings)
  • Address all code review feedback
  • Use idiomatic Rust patterns (&str vs &String)
  • Fix code formatting with cargo fmt

Behavior

With gh CLI:

  • Respects user's git_protocol config (https/ssh)
  • Automatically uses token from gh auth token
  • Zero configuration needed

Without gh CLI:

  • Defaults to HTTPS (matching gh's default)
  • Requires explicit --github-token with helpful error message
  • Fully backwards compatible

Quality Metrics

  • ✅ 19/19 tests passing
  • ✅ 0 clippy warnings
  • ✅ Idiomatic Rust code
  • ✅ Conventional commits
  • ✅ Secure token handling
  • ✅ Backwards compatible
  • ✅ Properly formatted with cargo fmt
Original prompt

When interacting with github, e.g. constructing git clone URLs and using github token, right now we

  • sometimes make assumptions for the user e.g. defaulting to ssh clone urls, when the user might be using http urls
  • sometimes we force users to supply github token even though they might have the gh command line utility installed and we could retrieve a token from there (via gh auth token).

Make sure to use conventional commits, and make sure to reduce blurps to README files etc to a minimum.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 29, 2025 19:04
- Create gh.rs module for GitHub CLI integration
- Read git_protocol from gh config (defaults to https)
- Automatically retrieve token from gh auth token if not provided
- Make github_token optional in import command
- Update git clone URLs based on configured protocol
- Add comprehensive tests for all new functionality
- Works gracefully without gh CLI installed

Co-authored-by: stefreak <139624+stefreak@users.noreply.github.com>
- Remove unused is_gh_available function
- Remove unnecessary clone by passing reference
- Update function signature to accept Option<&String>

Co-authored-by: stefreak <139624+stefreak@users.noreply.github.com>
- Change get_token_with_fallback to accept Option<&str>
- Use as_deref() for cleaner Option<String> to Option<&str> conversion

Co-authored-by: stefreak <139624+stefreak@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix assumptions in GitHub clone URL handling feat: integrate gh CLI for protocol config and token auto-discovery Nov 29, 2025
Copilot AI requested a review from stefreak November 29, 2025 19:17
@stefreak stefreak marked this pull request as ready for review November 29, 2025 19:20
@stefreak
Copy link
Copy Markdown
Owner

@copilot fix formatting

Co-authored-by: stefreak <139624+stefreak@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 29, 2025

@copilot fix formatting

Fixed formatting with cargo fmt in commit 3298cc6. All code now follows Rust formatting conventions.

@stefreak stefreak merged commit 2e2688c into main Nov 29, 2025
2 checks passed
@stefreak stefreak deleted the copilot/fix-clone-url-assumptions branch November 29, 2025 19:38
@github-actions github-actions Bot mentioned this pull request Nov 29, 2025
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