From f84b658530c0c0eaaaa0473add8c8c359fa6b09e Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 16 Feb 2026 22:39:51 +0000 Subject: feat: add --offline flag to list, checkout, apply commands Skip network fetch when --offline is set, using only local cache --- src/bin/ngit/sub_commands/checkout.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/bin/ngit/sub_commands/checkout.rs') diff --git a/src/bin/ngit/sub_commands/checkout.rs b/src/bin/ngit/sub_commands/checkout.rs index 2fc9a09..19e39d0 100644 --- a/src/bin/ngit/sub_commands/checkout.rs +++ b/src/bin/ngit/sub_commands/checkout.rs @@ -28,7 +28,7 @@ use crate::{ repo_ref::get_repo_coordinates_when_remote_unknown, }; -pub async fn launch(id: &str) -> Result<()> { +pub async fn launch(id: &str, offline: bool) -> Result<()> { let event_id = parse_event_id(id)?; let git_repo = Repo::discover().context("failed to find a git repository")?; @@ -44,10 +44,12 @@ pub async fn launch(id: &str) -> Result<()> { .ok() .flatten(); - if let Some((remote_name, _)) = &nostr_remote { - run_git_fetch(remote_name)?; - } else { - fetching_with_report(git_repo_path, &client, &repo_coordinates).await?; + if !offline { + if let Some((remote_name, _)) = &nostr_remote { + run_git_fetch(remote_name)?; + } else { + fetching_with_report(git_repo_path, &client, &repo_coordinates).await?; + } } let repo_ref = get_repo_ref_from_cache(Some(git_repo_path), &repo_coordinates).await?; -- cgit v1.2.3