+3
appview/state/git_http.go
+3
appview/state/git_http.go
+13
knotserver/git.go
+13
knotserver/git.go
···
6
6
"io"
7
7
"net/http"
8
8
"path/filepath"
9
+
"strings"
9
10
10
11
securejoin "github.com/cyphar/filepath-securejoin"
11
12
"github.com/go-chi/chi/v5"
···
113
114
w.WriteHeader(http.StatusForbidden)
114
115
115
116
fmt.Fprintf(w, "Welcome to Tangled.sh!\n\nPushes are currently only supported over SSH.")
117
+
118
+
// If the appview gave us the repository owner's handle we can attempt to
119
+
// construct the correct ssh url.
120
+
ownerHandle := r.Header.Get("x-tangled-repo-owner-handle")
121
+
if ownerHandle != "" && !strings.ContainsAny(ownerHandle, ":") {
122
+
hostname := d.c.Server.Hostname
123
+
if strings.Contains(hostname, ":") {
124
+
hostname = strings.Split(hostname, ":")[0]
125
+
}
126
+
127
+
fmt.Fprintf(w, " Try:\ngit remote set-url --push origin git@%s:%s/%s\n\n... and push again.", hostname, ownerHandle, unqualifiedRepoName)
128
+
}
116
129
fmt.Fprintf(w, "\n\n")
117
130
}
118
131