-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Cache submodule into git db #16246
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
base: master
Are you sure you want to change the base?
Cache submodule into git db #16246
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,12 @@ | ||
| //! Utilities for handling git repositories, mainly around | ||
| //! authentication/cloning. | ||
|
|
||
| use crate::core::{GitReference, Verbosity}; | ||
| use crate::core::{GitReference, SourceId, Verbosity}; | ||
| use crate::sources::git::fetch::RemoteKind; | ||
| use crate::sources::git::oxide; | ||
| use crate::sources::git::oxide::cargo_config_to_gitoxide_overrides; | ||
| use crate::sources::git::source::GitSource; | ||
| use crate::sources::source::Source as _; | ||
| use crate::util::HumanBytes; | ||
| use crate::util::errors::{CargoResult, GitCliError}; | ||
| use crate::util::{GlobalContext, IntoUrl, MetricsCounter, Progress, network}; | ||
|
|
@@ -447,7 +449,7 @@ impl<'a> GitCheckout<'a> { | |
| let target = repo.head()?.target(); | ||
| Ok((target, repo)) | ||
| }); | ||
| let mut repo = match head_and_repo { | ||
| let repo = match head_and_repo { | ||
| Ok((head, repo)) => { | ||
| if child.head_id() == head { | ||
| return update_submodules(&repo, gctx, &child_remote_url); | ||
|
|
@@ -461,24 +463,23 @@ impl<'a> GitCheckout<'a> { | |
| } | ||
| }; | ||
| // Fetch data from origin and reset to the head commit | ||
| let reference = GitReference::Rev(head.to_string()); | ||
| gctx.shell() | ||
| .status("Updating", format!("git submodule `{child_remote_url}`"))?; | ||
| fetch( | ||
| &mut repo, | ||
| &child_remote_url, | ||
| &reference, | ||
| let mut source = GitSource::new( | ||
| SourceId::from_url(&format!("git+{child_remote_url}#{head}"))?, | ||
| gctx, | ||
| RemoteKind::GitDependency, | ||
| ) | ||
| .with_context(|| { | ||
| let name = child.name().unwrap_or(""); | ||
| format!("failed to fetch submodule `{name}` from {child_remote_url}",) | ||
| })?; | ||
|
||
| source.set_quiet(true); | ||
|
|
||
| let (db, actual_rev) = source.update_db()?; | ||
| db.copy_to(actual_rev, &repo.path(), gctx)?; | ||
|
|
||
| let obj = repo.find_object(head, None)?; | ||
| reset(&repo, &obj, gctx)?; | ||
| update_submodules(&repo, gctx, &child_remote_url) | ||
| reset(&repo, &obj, gctx) | ||
|
||
| } | ||
| } | ||
| } | ||
|
|
||
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.
What impact does this have on our progress bars?
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.
Mostly the same? The old fetch will have a single progress bar, which now changes into a progress bar for update_db and a brief progress bar after for db.copy. This progress bars behavior should be the same as when update git source. Most of the time I don't even notice the brief one.