-
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
Open
avnyu
wants to merge
5
commits into
rust-lang:master
Choose a base branch
from
avnyu:cached-submodules
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+174
−80
Open
Cache submodule into git db #16246
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c6c0f76
refactor: extract into GitSource::fetch_db
avnyu 26ffef4
feat: recursive cache git submodules
avnyu 3de3173
fix(test): reflect cache git submodules changes
avnyu c863e3d
test: add case for cached git submodule
avnyu a474768
fix: remove extra 'update git submodule' when the submodule is cached
avnyu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1060,7 +1060,10 @@ Caused by: | |
| failed to update submodule `src` | ||
|
|
||
| Caused by: | ||
| object not found - no match for id ([..]); class=Odb (9); code=NotFound (-3) | ||
| failed to fetch submodule `src` from [ROOTURL]/dep2 | ||
|
|
||
| Caused by: | ||
| revspec '[..]' not found; class=Reference (4); code=NotFound (-3) | ||
|
|
||
| "#]]; | ||
|
|
||
|
|
@@ -4269,3 +4272,73 @@ src/main.rs | |
| "#]]) | ||
| .run(); | ||
| } | ||
|
|
||
| #[cargo_test] | ||
| fn dep_with_cached_submodule() { | ||
| let project = project(); | ||
| let git_project = git::new("dep1", |project| { | ||
| project.file("Cargo.toml", &basic_manifest("dep1", "0.5.0")) | ||
| }); | ||
| let git_project2 = git::new("dep2", |project| { | ||
| project.file("Cargo.toml", &basic_manifest("dep2", "0.5.0")) | ||
| }); | ||
| let git_project3 = git::new("dep3", |project| project.file("lib.rs", "pub fn dep() {}")); | ||
|
|
||
| let url = git_project3.root().to_url().to_string(); | ||
|
|
||
| let repo = git2::Repository::open(&git_project.root()).unwrap(); | ||
| git::add_submodule(&repo, &url, Path::new("src")); | ||
| git::commit(&repo); | ||
|
|
||
| let repo2 = git2::Repository::open(&git_project2.root()).unwrap(); | ||
| git::add_submodule(&repo2, &url, Path::new("src")); | ||
| git::commit(&repo2); | ||
|
|
||
| let project = project | ||
| .file( | ||
| "Cargo.toml", | ||
| &format!( | ||
| r#" | ||
| [package] | ||
|
|
||
| name = "foo" | ||
| version = "0.5.0" | ||
| edition = "2015" | ||
| authors = ["[email protected]"] | ||
|
|
||
| [dependencies.dep1] | ||
| git = '{}' | ||
|
|
||
| [dependencies.dep2] | ||
| git = '{}' | ||
|
|
||
| "#, | ||
| git_project.url(), | ||
| git_project2.url(), | ||
| ), | ||
| ) | ||
| .file( | ||
| "src/lib.rs", | ||
| r#" | ||
| extern crate dep1; pub fn foo() { dep1::dep() } | ||
| extern crate dep2; pub fn bar() { dep2::dep() } | ||
| "#, | ||
| ) | ||
| .build(); | ||
|
|
||
| // only update submodule once | ||
| project | ||
| .cargo("check") | ||
| .with_stderr_data(str![[r#" | ||
| [UPDATING] git repository `[ROOTURL]/dep1` | ||
| [UPDATING] git submodule `[ROOTURL]/dep3` | ||
| [UPDATING] git repository `[ROOTURL]/dep2` | ||
| [LOCKING] 2 packages to latest compatible versions | ||
| [CHECKING] dep[..] v0.5.0 ([ROOTURL]/dep[..]#[..]) | ||
| [CHECKING] dep[..] v0.5.0 ([ROOTURL]/dep[..]#[..]) | ||
| [CHECKING] foo v0.5.0 ([ROOT]/foo) | ||
| [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s | ||
|
|
||
| "#]]) | ||
| .run(); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[not specific to this file]
[not hard blockers]
I noticed that in the commit history we have
Merge branch 'master' of https://…. We encourage rebasing and having a well-structured git history for review/debugging/tracing purpose.Also,
chore: …were used in some commits, butchoreshould have not production code change (see https://stackoverflow.com/a/26944812). IMO they should either berefactororfix.(Some may be better being squashed into the entire fix ffd78e6, as those intermediates commits minimally help future review and code tracing)
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.
Fixed, I won't merge unless needed