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/list.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/bin/ngit/sub_commands/list.rs') diff --git a/src/bin/ngit/sub_commands/list.rs b/src/bin/ngit/sub_commands/list.rs index fc0883a..80eec21 100644 --- a/src/bin/ngit/sub_commands/list.rs +++ b/src/bin/ngit/sub_commands/list.rs @@ -95,7 +95,7 @@ fn run_git_fetch(remote_name: &str) -> Result<()> { } #[allow(clippy::too_many_lines)] -pub async fn launch(status: String, json: bool, id: Option) -> Result<()> { +pub async fn launch(status: String, json: bool, id: Option, offline: bool) -> Result<()> { if std::env::var("NGIT_INTERACTIVE_MODE").is_ok() { return launch_interactive().await; } @@ -113,14 +113,16 @@ pub async fn launch(status: String, json: bool, id: Option) -> Result<() .ok() .flatten(); - if let Some((remote_name, _)) = &nostr_remote { - if std::env::var("NGITTEST").is_ok() { - fetching_with_report(git_repo_path, &client, &repo_coordinates).await?; + if !offline { + if let Some((remote_name, _)) = &nostr_remote { + if std::env::var("NGITTEST").is_ok() { + fetching_with_report(git_repo_path, &client, &repo_coordinates).await?; + } else { + run_git_fetch(remote_name)?; + } } else { - run_git_fetch(remote_name)?; + fetching_with_report(git_repo_path, &client, &repo_coordinates).await?; } - } 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