From 0138c3a17f425172232c5a09a5673b35fba0891b Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 25 Dec 2025 20:05:18 -0600 Subject: [PATCH] Implement nostrPull (not sure about it) --- src/lib/git.ts | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/lib/git.ts b/src/lib/git.ts index 03db47bb..fa85685e 100644 --- a/src/lib/git.ts +++ b/src/lib/git.ts @@ -800,8 +800,39 @@ export class Git { return result; } - private async nostrPull(nostrURI: NostrURI, options: Omit[0], 'fs' | 'http' | 'corsProxy'> & { remote: string; dir: string }): Promise { - // TODO: implement Nostr pull + private async nostrPull(nostrURI: NostrURI, options: Omit[0], 'fs' | 'http' | 'corsProxy'> & { remote: string; dir: string; author: { name: string; email: string } }): Promise { + // First, fetch the latest changes from Nostr + await this.nostrFetch(nostrURI, options); + + // Get the current branch + const ref = options.ref || await git.currentBranch({ + fs: this.fs, + dir: options.dir, + }); + + if (!ref) { + throw new Error('Not on a branch'); + } + + // Construct the remote branch ref + const remoteRef = options.remoteRef || await git.getConfig({ + fs: this.fs, + dir: options.dir, + path: `branch.${ref}.merge`, + }); + + if (!remoteRef) { + throw new Error(`No remote ref configured for branch ${ref}`); + } + + // Merge the remote branch into the current branch + await git.merge({ + fs: this.fs, + dir: options.dir, + ours: ref, + theirs: remoteRef, + author: options.author, + }); } private async nostrPush(nostrURI: NostrURI, options: Omit[0], 'fs' | 'http' | 'onAuth' | 'corsProxy'>) {