upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/sub_commands/list.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-16 22:39:51 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-17 11:38:24 +0000
commitf84b658530c0c0eaaaa0473add8c8c359fa6b09e (patch)
tree51617dde282f6d1161fdbf9b929a9f1e8f9ead6c /src/bin/ngit/sub_commands/list.rs
parent17d31258117ec51d0e79c488ed8f863ad47b945f (diff)
feat: add --offline flag to list, checkout, apply commands
Skip network fetch when --offline is set, using only local cache
Diffstat (limited to 'src/bin/ngit/sub_commands/list.rs')
-rw-r--r--src/bin/ngit/sub_commands/list.rs16
1 files changed, 9 insertions, 7 deletions
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<()> {
95} 95}
96 96
97#[allow(clippy::too_many_lines)] 97#[allow(clippy::too_many_lines)]
98pub async fn launch(status: String, json: bool, id: Option<String>) -> Result<()> { 98pub async fn launch(status: String, json: bool, id: Option<String>, offline: bool) -> Result<()> {
99 if std::env::var("NGIT_INTERACTIVE_MODE").is_ok() { 99 if std::env::var("NGIT_INTERACTIVE_MODE").is_ok() {
100 return launch_interactive().await; 100 return launch_interactive().await;
101 } 101 }
@@ -113,14 +113,16 @@ pub async fn launch(status: String, json: bool, id: Option<String>) -> Result<()
113 .ok() 113 .ok()
114 .flatten(); 114 .flatten();
115 115
116 if let Some((remote_name, _)) = &nostr_remote { 116 if !offline {
117 if std::env::var("NGITTEST").is_ok() { 117 if let Some((remote_name, _)) = &nostr_remote {
118 fetching_with_report(git_repo_path, &client, &repo_coordinates).await?; 118 if std::env::var("NGITTEST").is_ok() {
119 fetching_with_report(git_repo_path, &client, &repo_coordinates).await?;
120 } else {
121 run_git_fetch(remote_name)?;
122 }
119 } else { 123 } else {
120 run_git_fetch(remote_name)?; 124 fetching_with_report(git_repo_path, &client, &repo_coordinates).await?;
121 } 125 }
122 } else {
123 fetching_with_report(git_repo_path, &client, &repo_coordinates).await?;
124 } 126 }
125 127
126 let repo_ref = get_repo_ref_from_cache(Some(git_repo_path), &repo_coordinates).await?; 128 let repo_ref = get_repo_ref_from_cache(Some(git_repo_path), &repo_coordinates).await?;