grasp: repository path uses the pubkey now.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -142,6 +143,10 @@ func (gs *GraspServer) validatePush(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gs *GraspServer) getRepositoryPath(pubkey nostr.PubKey, repoName string) string {
|
||||||
|
return filepath.Join(gs.RepositoryDir, pubkey.Hex(), repoName)
|
||||||
|
}
|
||||||
|
|
||||||
// repoExists checks if a repository has an announcement event (kind 30617)
|
// repoExists checks if a repository has an announcement event (kind 30617)
|
||||||
func (gs *GraspServer) repoExists(pubkey nostr.PubKey, repoName string) bool {
|
func (gs *GraspServer) repoExists(pubkey nostr.PubKey, repoName string) bool {
|
||||||
for range gs.Relay.QueryStored(context.Background(), nostr.Filter{
|
for range gs.Relay.QueryStored(context.Background(), nostr.Filter{
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ func (gs *GraspServer) handleInfoRefs(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
repoPath := filepath.Join(gs.RepositoryDir, repoName)
|
repoPath := gs.getRepositoryPath(pubkey, repoName)
|
||||||
serviceName := r.URL.Query().Get("service")
|
serviceName := r.URL.Query().Get("service")
|
||||||
|
|
||||||
w.Header().Set("Connection", "Keep-Alive")
|
w.Header().Set("Connection", "Keep-Alive")
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"fiatjaf.com/nostr"
|
"fiatjaf.com/nostr"
|
||||||
@@ -20,7 +19,7 @@ func (gs *GraspServer) handleGitUploadPack(
|
|||||||
pubkey nostr.PubKey,
|
pubkey nostr.PubKey,
|
||||||
repoName string,
|
repoName string,
|
||||||
) {
|
) {
|
||||||
repoPath := filepath.Join(gs.RepositoryDir, repoName)
|
repoPath := gs.getRepositoryPath(pubkey, repoName)
|
||||||
|
|
||||||
// for upload-pack (pull), check if repository exists
|
// for upload-pack (pull), check if repository exists
|
||||||
if !gs.repoExists(pubkey, repoName) {
|
if !gs.repoExists(pubkey, repoName) {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
@@ -45,7 +44,7 @@ func (gs *GraspServer) handleGitReceivePack(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repoPath := filepath.Join(gs.RepositoryDir, repoName)
|
repoPath := gs.getRepositoryPath(pubkey, repoName)
|
||||||
|
|
||||||
// initialize git repo if it doesn't exist
|
// initialize git repo if it doesn't exist
|
||||||
if _, err := os.Stat(repoPath); os.IsNotExist(err) {
|
if _, err := os.Stat(repoPath); os.IsNotExist(err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user