-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use proper git URL for GitHub repos #11475
Conversation
It can be seen in the following link that a git repo URL from GitHub should end with ".git": https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#about-remote-repositories
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the patch.
Could you provide a reference saying that URL without .git
suffix is inappropriate? I know this is somewhat a convention, but I couldn't find any official doc from GitHub telling their preference.
It also needs a bit more work to interact with URL containing .git
. See
cargo/src/cargo/sources/git/utils.rs
Lines 1163 to 1165 in 4a8d17e
// Trim off the `.git` from the repository, if present, since that's | |
// optional for GitHub and won't work when we try to use the API as well. | |
let repository = repository.strip_suffix(".git").unwrap_or(repository); |
Personally, I lean towards leaving it as-is.
I can't find one either.
I would prefer to stick to what the repo hosting service provides.
IMO the comment in code is misleading, or at least it misunderstood it.
My understanding is that "repo URL" != "repo name" as the former could be a link to a git bare repo (which would contains ".git" suffix). |
Thank you for the response! I also like the explicitness of
I doubt it. Bare repositories are less useful for average GitHub users. And average GitHub users usually expect a repo to have a working directory. We could have a contact to people from GitHub and see if cloning one or the other can reduce the stress of their services, though I also guess not, as cloning without
GitHub as a service can choose any kind of infra to help themselves. This could be nothing related to us cloning bare repos without
I believe "repo URL" != "repo name" is why Cargo chops |
Just to clarify myself. I realized I chosen my word badly... What I actually meant is: when creating a new git repo on github. Github probably creates a bare repo (or something alike internally) and therefore they expose the url with the .git suffix (to follow the convention?). Anyway, this is just guesswork and I still couldn't find github statement on it.
I think there are misunderstanding here (poor choice of words from me). |
Indeed. I believe GitHub uses something similar internally, but I am still not convinced that GitHub wants users to perceive the existence of bare repositories, given that it probably wouldn't bring any value to GitHub. Who else needs to know how a git server works when 99.9% of one's time on git is being a dumb client? Anyway, it's really not useful for us debating here without any information from GitHub people. I do want to merge this pull request as myself loves |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I guess what GitHub tries to replicate is somewhat a DWIM like the following: https://github.com/git/git/blob/c48035d29b4e524aed3a32f0403676f0d9128863/path.c#L772-L791
That works fine with file:
protocol with official git
CLI. That said, you're completely correct that a tool probably shouldn't rely on the undocumented behaviour. Although the actual convenience path is determined by either Cargo or git services, Cargo's doc could have a more consistent view of what a GIT_URL looks like even it doesn't affect any actual behaviour.
Sorry for being like a dumbass, and thank you for your patience!
@bors r+ |
☀️ Test successful - checks-actions |
@weihanglo |
8 commits in 70898e522116f6c23971e2a554b2dc85fd4c84cd..cc0a320879c17207bbfb96b5d778e28a2c62030d 2022-12-05 19:43:44 +0000 to 2022-12-14 14:46:57 +0000 - artifact deps should works when target field specified coexists with `optional = true` (rust-lang/cargo#11434) - Add `home` crate to cargo crates (rust-lang/cargo#11359) - Use proper git URL for GitHub repos (rust-lang/cargo#11475) - Fixes flock(fd, LOCK_UN) emulation on Solaris. (rust-lang/cargo#11474) - Allow Check targets needed for optional doc-scraping to fail without killing the build (rust-lang/cargo#11450) - fix: gleaning rustdocflags from `target.cfg(…)` is not supported (rust-lang/cargo#11323) - Fix typo (rust-lang/cargo#11470) - resolver.md: Fix naming in example (rust-lang/cargo#11469)
Update cargo 8 commits in 70898e522116f6c23971e2a554b2dc85fd4c84cd..cc0a320879c17207bbfb96b5d778e28a2c62030d 2022-12-05 19:43:44 +0000 to 2022-12-14 14:46:57 +0000 - artifact deps should works when target field specified coexists with `optional = true` (rust-lang/cargo#11434) - Add `home` crate to cargo crates (rust-lang/cargo#11359) - Use proper git URL for GitHub repos (rust-lang/cargo#11475) - Fixes flock(fd, LOCK_UN) emulation on Solaris. (rust-lang/cargo#11474) - Allow Check targets needed for optional doc-scraping to fail without killing the build (rust-lang/cargo#11450) - fix: gleaning rustdocflags from `target.cfg(…)` is not supported (rust-lang/cargo#11323) - Fix typo (rust-lang/cargo#11470) - resolver.md: Fix naming in example (rust-lang/cargo#11469) r? `@ghost`
It can be seen in the following link that a git repo URL from GitHub should end with ".git": https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#about-remote-repositories