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
Fix regression in unmatched globs error message #10595
Changes from all 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 |
---|---|---|
|
@@ -213,16 +213,15 @@ fn remove_prefix_request_to_digest( | |
let store = core.store(); | ||
|
||
async move { | ||
let input_digest = lift_digest(&externs::project_ignoring_type(&args[0], "digest"))?; | ||
let input_digest = | ||
lift_digest(&externs::project_ignoring_type(&args[0], "digest")).map_err(|e| throw(&e))?; | ||
let prefix = externs::project_str(&args[0], "prefix"); | ||
let digest = store | ||
.strip_prefix(input_digest, PathBuf::from(prefix)) | ||
.await | ||
.map_err(|e| format!("{:?}", e))?; | ||
let res: Result<_, String> = Ok(Snapshot::store_directory(&core, &digest)); | ||
res | ||
.map_err(|e| throw(&format!("{:?}", e)))?; | ||
Ok(Snapshot::store_directory(&core, &digest)) | ||
} | ||
.map_err(|e: String| throw(&e)) | ||
.boxed() | ||
} | ||
|
||
|
@@ -233,16 +232,15 @@ fn add_prefix_request_to_digest( | |
let core = context.core; | ||
let store = core.store(); | ||
async move { | ||
let input_digest = lift_digest(&externs::project_ignoring_type(&args[0], "digest"))?; | ||
let input_digest = | ||
lift_digest(&externs::project_ignoring_type(&args[0], "digest")).map_err(|e| throw(&e))?; | ||
let prefix = externs::project_str(&args[0], "prefix"); | ||
let digest = store | ||
.add_prefix(input_digest, PathBuf::from(prefix)) | ||
.await | ||
.map_err(|e| format!("{:?}", e))?; | ||
let res: Result<_, String> = Ok(Snapshot::store_directory(&core, &digest)); | ||
res | ||
.map_err(|e| throw(&format!("{:?}", e)))?; | ||
Ok(Snapshot::store_directory(&core, &digest)) | ||
} | ||
.map_err(|e: String| throw(&e)) | ||
.boxed() | ||
} | ||
|
||
|
@@ -270,13 +268,11 @@ fn merge_digests_request_to_digest( | |
.collect(); | ||
async move { | ||
let digest = store | ||
.merge(digests?) | ||
.merge(digests.map_err(|e| throw(&e))?) | ||
.await | ||
.map_err(|e| format!("{:?}", e))?; | ||
let res: Result<_, String> = Ok(Snapshot::store_directory(&core, &digest)); | ||
res | ||
.map_err(|e| throw(&format!("{:?}", e)))?; | ||
Ok(Snapshot::store_directory(&core, &digest)) | ||
} | ||
.map_err(|err: String| throw(&err)) | ||
.boxed() | ||
} | ||
|
||
|
@@ -286,15 +282,10 @@ fn download_file_to_digest( | |
) -> BoxFuture<'static, NodeResult<Value>> { | ||
let core = context.core.clone(); | ||
async move { | ||
let key = externs::acquire_key_for(args.pop().unwrap()).map_err(|e| format!("{:?}", e))?; | ||
let snapshot = context | ||
.get(DownloadedFile(key)) | ||
.await | ||
.map_err(|e| format!("{:?}", e))?; | ||
let res: Result<_, String> = Ok(Snapshot::store_directory(&core, &snapshot.digest)); | ||
res | ||
let key = externs::acquire_key_for(args.pop().unwrap())?; | ||
let snapshot = context.get(DownloadedFile(key)).await?; | ||
Ok(Snapshot::store_directory(&core, &snapshot.digest)) | ||
} | ||
.map_err(|err: String| throw(&err)) | ||
.boxed() | ||
} | ||
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actual fix for |
||
|
||
|
@@ -304,15 +295,10 @@ fn path_globs_to_digest( | |
) -> BoxFuture<'static, NodeResult<Value>> { | ||
let core = context.core.clone(); | ||
async move { | ||
let key = externs::acquire_key_for(args.pop().unwrap()).map_err(|e| format!("{:?}", e))?; | ||
let digest = context | ||
.get(Snapshot(key)) | ||
.await | ||
.map_err(|e| format!("{:?}", e))?; | ||
let res: Result<_, String> = Ok(Snapshot::store_directory(&core, &digest)); | ||
res | ||
let key = externs::acquire_key_for(args.pop().unwrap())?; | ||
let digest = context.get(Snapshot(key)).await?; | ||
Ok(Snapshot::store_directory(&core, &digest)) | ||
} | ||
.map_err(|err: String| throw(&err)) | ||
Comment on lines
-307
to
-315
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actual fix for |
||
.boxed() | ||
} | ||
|
||
|
@@ -343,12 +329,13 @@ fn create_digest_to_digest( | |
let store = context.core.store(); | ||
|
||
async move { | ||
let digests = future::try_join_all(digests).await?; | ||
let digest = store.merge(digests).await.map_err(|e| format!("{:?}", e))?; | ||
let res: Result<_, String> = Ok(Snapshot::store_directory(&context.core, &digest)); | ||
res | ||
let digests = future::try_join_all(digests).await.map_err(|e| throw(&e))?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the part that fixes it (because we don't call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, only a refactor. |
||
let digest = store | ||
.merge(digests) | ||
.await | ||
.map_err(|e| throw(&format!("{:?}", e)))?; | ||
Ok(Snapshot::store_directory(&context.core, &digest)) | ||
} | ||
.map_err(|err: String| throw(&err)) | ||
.boxed() | ||
} | ||
|
||
|
@@ -360,18 +347,15 @@ fn digest_subset_to_digest( | |
let store = context.core.store(); | ||
|
||
async move { | ||
let path_globs = Snapshot::lift_path_globs(&globs)?; | ||
let original_digest = lift_digest(&externs::project_ignoring_type(&args[0], "digest"))?; | ||
let path_globs = Snapshot::lift_path_globs(&globs).map_err(|e| throw(&e))?; | ||
let original_digest = | ||
lift_digest(&externs::project_ignoring_type(&args[0], "digest")).map_err(|e| throw(&e))?; | ||
let subset_params = SubsetParams { globs: path_globs }; | ||
|
||
let digest = store | ||
.subset(original_digest, subset_params) | ||
.await | ||
.map_err(|e| format!("{:?}", e))?; | ||
|
||
let res: Result<_, String> = Ok(Snapshot::store_directory(&context.core, &digest)); | ||
res | ||
.map_err(|e| throw(&format!("{:?}", e)))?; | ||
Ok(Snapshot::store_directory(&context.core, &digest)) | ||
} | ||
.map_err(|err: String| throw(&err)) | ||
.boxed() | ||
} |
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.
Note that this change and most others are not necessary. The only thing we need is the fix for
download_file_to_digest
andpath_globs_to_digest
.But, personally, I think I find this refactor easier to follow and that it has less coercion of types, like no
let Result<_, String>
. Still, let me know if this is actually an improvement or I should revert to the old.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.
The one concern I have about this hunk is that it seems to add two
throw()
conversions where there were none before. Is it possible to keep those as string errors and then re-use the.map_err()
at the bottom? Or is the point of this part that you have to add those twothrow()
s in order to remove thelet res
statement?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.
I think removing the
let res
is clearer regardless, so I'm fine if we make this tradeoff.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.
This is only part of the refactor. The end effect should be the same, so it's only a question of what's clearer here.
I added comments on the two code blocks that are the actual fixes. Everything else can be reverted if preferred.
Pardon that I didn't make that clearer from the start, and thank you for the prompt feedback :)