Skip to content

Support GitHub and GitLab URLs#7

Merged
artob merged 3 commits into
dryrust:masterfrom
SamuelSarle:master
Jun 10, 2025
Merged

Support GitHub and GitLab URLs#7
artob merged 3 commits into
dryrust:masterfrom
SamuelSarle:master

Conversation

@SamuelSarle
Copy link
Copy Markdown
Collaborator

Supports fetching a single file given git://<host>/<owner>/<repo>/<branch_or_commit>/<path>.

$ cargo run -q -- git://github.com/dryrust/gofer.rs/master/VERSION
0.1.4

$ cargo run -q -- git://github.com/dryrust/gofer.rs/f4ea4a585c009aefd570cefcb6062dc5d579c6ab/VERSION
0.1.4

$ cargo run -q -- git://gitlab.com/rust-lang/rust/master/src/version
1.89.0

$ cargo run -q -- git://gitlab.com/rust-lang/rust/c6a955468b025dbe3d1de3e8f3e30496d1fb7f40/src/version
1.89.0

Closes #3

`ref/heads/<branch>` is only for branches and leaving it out supports either.
@SamuelSarle SamuelSarle requested a review from artob as a code owner June 10, 2025 19:18
@artob artob self-assigned this Jun 10, 2025
@artob artob added the enhancement New feature or request label Jun 10, 2025
@artob artob changed the title Implement fetching git resources. Support GitHub URLs Jun 10, 2025
@artob artob requested a review from Copilot June 10, 2025 21:08
@artob
Copy link
Copy Markdown
Contributor

artob commented Jun 10, 2025

@race-of-sloths invite

@race-of-sloths
Copy link
Copy Markdown

race-of-sloths commented Jun 10, 2025

@SamuelSarle Thank you for your contribution! Your pull request is now a part of the Race of Sloths!
Weekly streak is on the road, smart strategy! Secure your streak with another PR!

Shows inviting banner with latest news.

Shows profile picture for the author of the PR

Current status: executed
Reviewer Score
@race-of-sloths 2

Your contribution is much appreciated with a final score of 2!
You have received 21 (20 base + 5% lifetime bonus) Sloth points for this contribution

@SamuelSarle, welcome to the Hall of Sloth fame! You have been honored with a Bronze rank and a 5% lifetime bonus to all rating points you earn with your next contributions!

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths and receive a reward
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

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 support for the git:// URL scheme by mapping GitHub and GitLab git URLs to their raw content endpoints and fetching them via reqwest.

  • Implements open() for git:// URLs in lib/gofer/src/schemes/git.rs, including URL mapping and HTTP GET.
  • Introduces a new InvalidGitUrl error variant and conversion in lib/gofer/src/error.rs.
  • Updates Cargo features (enables git by default) and provides a usage example in lib/gofer/examples/git.rs.

Reviewed Changes

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

File Description
lib/gofer/src/schemes/git.rs Implement open() and map_git_url_to_raw_url, add tests
lib/gofer/src/error.rs Add InvalidGitUrl error variant and From<Error> case
lib/gofer/examples/git.rs New example demonstrating git:// usage
lib/gofer/Cargo.toml Enable git in feature sets and adjust dependencies
Comments suppressed due to low confidence (3)

lib/gofer/src/schemes/git.rs:19

  • [nitpick] The variable client refers to a ClientBuilder, not the final Client. Consider renaming it to builder to clarify its role before calling .build().
let client = ClientBuilder::new()

lib/gofer/src/schemes/git.rs:79

  • Add negative tests for map_git_url_to_raw_url, e.g. invalid prefixes, too few components, or unsupported hosts, to verify proper error handling.
mod test {

lib/gofer/examples/git.rs:1

  • Include a comment or README note that the git feature must be enabled when running this example (e.g. cargo run --example git --features git).
// This is free and unencumbered software released into the public domain.

Comment thread lib/gofer/src/error.rs
@artob artob changed the title Support GitHub URLs Support GitHub and GitLab URLs Jun 10, 2025
Copy link
Copy Markdown
Contributor

@artob artob left a comment

Choose a reason for hiding this comment

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

LGTM. Good work!

@artob artob merged commit 8e87826 into dryrust:master Jun 10, 2025
0 of 2 checks passed
@race-of-sloths
Copy link
Copy Markdown

🥁 Score it!

@artob, please score the PR with @race-of-sloths score [1/2/3/5/8/13]. The contributor deserves it.
If no scoring is provided within 24 hours, this PR will be scored as 2 🦥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

Implement Git protocol support

4 participants