consolidate git operations into a Repo type

This commit is contained in:
2026-10-03 12:46:44 +07:00
parent 4656f1340b
commit 49d351fe06
21 changed files with 2243 additions and 2203 deletions
+11 -10
View File
@@ -12,7 +12,7 @@ use signed_core::{
Announcement, Deletions, Filters, GitEvent, PullRequest, RepoAddr, RepoState, RepoStatus,
filters,
};
use signed_git::Nip34Binding;
use signed_git::{Nip34Binding, PatchParser, Repo};
use signed_nostr::UniversalSigner;
use crate::backend::{
@@ -700,7 +700,7 @@ impl RepoStore {
return;
};
let series: Vec<String> = signed_git::split_patch_series(&patch)
let series: Vec<String> = PatchParser::split_patch_series(&patch)
.into_iter()
.map(str::to_owned)
.collect();
@@ -906,9 +906,9 @@ impl RepoStore {
let mut pushed = 0;
for (url, label) in &targets {
match signed_git::push_commit_ref(
&path, url, &tip, &reference,
) {
match Repo::open(&path)
.and_then(|repo| repo.push_ref(url, &tip, &reference))
{
Ok(()) => pushed += 1,
Err(e) => failures.push(format!("{label}: {e}")),
}
@@ -986,7 +986,7 @@ impl RepoStore {
let merge_base = merge_base.clone();
let compare_ref = compare_ref.clone();
async move {
signed_git::format_patch_between(&repo_path, &merge_base, &compare_ref)
Repo::open(&repo_path)?.format_patch_between(&merge_base, &compare_ref)
}
})
.await;
@@ -1037,7 +1037,7 @@ impl RepoStore {
return;
}
let series: Vec<String> = signed_git::split_patch_series(&patch)
let series: Vec<String> = PatchParser::split_patch_series(&patch)
.into_iter()
.map(str::to_owned)
.collect();
@@ -1368,7 +1368,9 @@ impl RepoStore {
let clone = {
let destination = destination.clone();
cx.background_spawn(async move { signed_git::clone_repo(&clone_urls, &destination) })
// The clone's repository handle is dropped in the task: gix handles
// are not `Send`, they must not cross the spawn boundary.
cx.background_spawn(async move { Repo::clone(&clone_urls, &destination).map(|_| ()) })
};
cx.spawn(async move |this, cx| {
@@ -1596,11 +1598,10 @@ fn comment_builder(
#[cfg(test)]
mod tests {
use signed_core::GitEvent;
use std::collections::HashSet;
use nostr_sdk::prelude::*;
use signed_core::GitEvent;
use super::{RepoStore, comment_builder, patch_current_commit};