upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-09-01 09:13:20 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-09-01 09:13:20 +0100
commit00d38ac675c69cacab3c4ad3ad1c34666c06d293 (patch)
treed7a0c130a7c62848311c86d3f0d53df9b277b4c4 /src
parent38d5f056d71f43a175c5ba1f2fd8e08691df27a9 (diff)
fix: list shows `/pr` PRs when git data is local
even if it is not on repository remotes, as it may have been pushed to a user's git server instead
Diffstat (limited to 'src')
-rw-r--r--src/bin/git_remote_nostr/list.rs22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs
index be83991..e6a4680 100644
--- a/src/bin/git_remote_nostr/list.rs
+++ b/src/bin/git_remote_nostr/list.rs
@@ -120,15 +120,6 @@ async fn get_open_and_draft_proposals_state(
120 // without trusting commit_id we must apply each patch which requires the oid of 120 // without trusting commit_id we must apply each patch which requires the oid of
121 // the parent so we much do a fetch 121 // the parent so we much do a fetch
122 122
123 // As we are fetching from git servers we mighgt as well get oids from pull
124 // request too
125 // TODO get Pull Request and Pull Request Update Events add these to
126 // refs/nostr/<event-id>
127 // TODO prepare PRs and PRS oids to try and fetch from repo servers that are or
128 // clone urls in PR/update event we are using anyway. TODO after we tried
129 // and failed to get them from these server we should fallback to fetch them
130 // from listed clone urls in PR/update but not during list, only during fetch
131
132 for (git_server_url, (oids_from_git_servers, is_grasp_server)) in remote_states { 123 for (git_server_url, (oids_from_git_servers, is_grasp_server)) in remote_states {
133 if fetch_from_git_server( 124 if fetch_from_git_server(
134 git_repo, 125 git_repo,
@@ -137,6 +128,8 @@ async fn get_open_and_draft_proposals_state(
137 .filter(|v| !v.starts_with("ref: ")) 128 .filter(|v| !v.starts_with("ref: "))
138 .cloned() 129 .cloned()
139 .collect::<Vec<String>>(), 130 .collect::<Vec<String>>(),
131 // TODO we could fetch the oids of Pull Requests and Pull Request Updates to prevent
132 // having repeat fetching during the git remote helper fetch phase
140 git_server_url, 133 git_server_url,
141 &repo_ref.to_nostr_git_url(&None), 134 &repo_ref.to_nostr_git_url(&None),
142 term, 135 term,
@@ -171,14 +164,15 @@ async fn get_open_and_draft_proposals_state(
171 { 164 {
172 match tag_value(pr_or_pr_update, "c") { 165 match tag_value(pr_or_pr_update, "c") {
173 Ok(tip) => { 166 Ok(tip) => {
174 // only list Pull Requests as refs/heads/pr/* if data is on a repo git 167 // only list Pull Requests as refs/heads/pr/* if data is commit is
175 // server otherwise the standard `git clone 168 // advertised as tip of a ref on a repo git server or
176 // nostr://` cmd will fail as it assumes all /refs/heads returned by 169 // available locally. Otherwise the standard cmd:
177 // list are accessable 170 // `git clone nostr://` will fail as it assumes all /refs/heads
171 // returned by list are accessable
178 let tip_oid_is_on_a_repo_git_server = 172 let tip_oid_is_on_a_repo_git_server =
179 remote_states.iter().any(|(_url, (state, _is_grasp))| { 173 remote_states.iter().any(|(_url, (state, _is_grasp))| {
180 state.iter().any(|(_, oid)| tip == *oid) 174 state.iter().any(|(_, oid)| tip == *oid)
181 }); 175 }) || git_repo.does_commit_exist(&tip).is_ok_and(|r| r);
182 176
183 if tip_oid_is_on_a_repo_git_server { 177 if tip_oid_is_on_a_repo_git_server {
184 state.insert(format!("refs/heads/{branch_name}"), tip); 178 state.insert(format!("refs/heads/{branch_name}"), tip);