-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
refactor: git source cleanup #12197
refactor: git source cleanup #12197
Conversation
r? @epage (rustbot has picked a reviewer for you, use r? to override) |
e2c61e9
to
f3653c8
Compare
@bors try |
💥 Test timed out |
All checks have passed but bors timed out. I have no idea. @bors try |
💥 Test timed out |
For being consistent with `GitDatabase`.
`orig_url` was unclear. Whose origin? `remote_url` is way more self-explanatory under a `git fetch` context.
The explanation is moved to be public from an inline comment.
Although this is only a few lines of code, I think it is still worth keeping it clean if it's not used by Cargo internally. Not to mention this apparently has an alternative solution at this moment, for example: ```diff - let oid = git_remote.rev_for(db_path, git_ref)?; + let oid = git_remote.db_at(db_path)?.resolve(git_ref)?; ``` From a naive research on GitHub, there is only one usage[^1] and it seems to be active but still experimental. Pardon my abrupt change breaking your project :( Only when we start considering what we want to expose can Cargo has a clearer boundaries between its subcrates. [^1]: https://github.com/trustification/source-distributed/blob/124ef26081a41330a553483441fca544bedbb473/src/git.rs#L34
It doesn't seem that they need to derive `Serialize`. Is there any other usage I am not aware of?
It was confusing and may lead to inconsistency that people need to pass both `path` and `repo` and ensure they are in sync.
This should be less controversial as the current logic share the same `GitRemote`. You can see the callsite of `GitDatabase::copy_to` use `self.url()`, which then calls into `self.remote.url(). When a `GitDatabase` is created, Cargo also uses `self.remote` as the remote of that `GitDatabase`.
f3653c8
to
88845b9
Compare
@epage. I believe this is ready. Do you have any concern with it? |
Sorry, missed that this was now ready @bors r+ |
☀️ Test successful - checks-actions |
☀️ Test successful - checks-actions |
👀 Test was successful, but fast-forwarding failed: 422 Changes must be made through a pull request. |
Update cargo 12 commits in b0fa79679e717cd077b7fc0fa4166f47107f1ba9..49b6d9e179a91cf7645142541c9563443f64bf2b 2023-06-03 14:19:48 +0000 to 2023-06-09 17:21:19 +0000 - docs: doc comments for all registry kinds (rust-lang/cargo#12247) - chore: Migrate print-ban from test to clippy (rust-lang/cargo#12246) - fix: fetch nested git submodules (rust-lang/cargo#12244) - refactor: registry source cleanup (rust-lang/cargo#12240) - test: loose overly matches for git cli output (rust-lang/cargo#12241) - fix: disable multiplexing on macOS for some versions of curl (rust-lang/cargo#12234) - docs: doc comments for registry source and index (rust-lang/cargo#12239) - doc: point to nightly cargo doc (rust-lang/cargo#12237) - Upgrade to `gix` v0.45 for multi-round pack negotiations. (rust-lang/cargo#12236) - refactor: git source cleanup (rust-lang/cargo#12197) - Add message on reusing previous temporary path on failed cargo installs (rust-lang/cargo#12231) - doc: the first line should be a simple sentence instead of a heading (rust-lang/cargo#12228) r? `@ghost`
What does this PR try to resolve?
I found some places can do minor refactors during documenting those items last week.
How should we test and review this PR?
Commit by commit. Each has its own explanation.
I believe the first four is not controversial. However, the last three do need to scrutinize
Serialize
. Did I miss some important contexts?repo
andpath
should always be in sync so there is no need to have two arguments. However,git2::Repository::path()
force UTF8 path on Windows. Will it cause any problem? I guess it may not since we already userepo.path()
somewhere in the codebase.Additional information