This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: add caching commands for patch and issue
In order to bootstrap the COB cache, and also in case of issues, supply a command for caching a set of patches/issues, or a single patch/issue. This is necessary since reads are not read-thru, it may appear that COBs are missing when in fact they haven't been cached when first moving over to the cache. Signed-off-by: Fintan Halpenny <[email protected]> X-Clacks-Overhead: GNU Terry Pratchett
- Loading branch information
Showing
4 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::ops::ControlFlow; | ||
|
||
use radicle::issue::IssueId; | ||
use radicle::storage::git::Repository; | ||
use radicle::Profile; | ||
|
||
use crate::terminal as term; | ||
|
||
pub fn run(id: Option<IssueId>, repository: &Repository, profile: &Profile) -> anyhow::Result<()> { | ||
let mut issues = profile.issues_mut(repository)?; | ||
|
||
match id { | ||
Some(id) => { | ||
issues.write(&id)?; | ||
term::success!("Successfully cached issue `{id}`"); | ||
} | ||
None => issues.write_all(|result, progress| { | ||
match result { | ||
Ok((id, _)) => term::success!("Successfully cached issue `{id}`"), | ||
Err(e) => term::warning(format!("Failed to retrieve issue: {e}")), | ||
}; | ||
term::info!("Cached {} of {}", progress.seen(), progress.total()); | ||
ControlFlow::Continue(()) | ||
})?, | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::ops::ControlFlow; | ||
|
||
use radicle::patch::PatchId; | ||
use radicle::storage::git::Repository; | ||
use radicle::Profile; | ||
|
||
use crate::terminal as term; | ||
|
||
pub fn run(id: Option<PatchId>, repository: &Repository, profile: &Profile) -> anyhow::Result<()> { | ||
let mut patches = profile.patches_mut(repository)?; | ||
|
||
match id { | ||
Some(id) => { | ||
patches.write(&id)?; | ||
term::success!("Successfully cached patch `{id}`"); | ||
} | ||
None => patches.write_all(|result, progress| { | ||
match result { | ||
Ok((id, _)) => term::success!("Successfully cached patch `{id}`"), | ||
Err(e) => term::warning(format!("Failed to retrieve patch: {e}")), | ||
}; | ||
term::info!("Cached {} of {}", progress.seen(), progress.total()); | ||
ControlFlow::Continue(()) | ||
})?, | ||
} | ||
|
||
Ok(()) | ||
} |