knotserver/internal: fix repo compare URL #658

Before this we incorrectly assumed that the git user Did was the same as the repo Did, this is not the case. We now take the repo Did as an argument to the replyCompare function

Signed-off-by: Samuel Shuert me@thecoded.prof

Changed files
+4 -4
knotserver
+4 -4
knotserver/internal.go
···
}
if (line.NewSha.String() != line.OldSha.String()) && line.OldSha.IsZero() {
-
msg, err := h.replyCompare(line, gitUserDid, gitRelativeDir, repoName, r.Context())
+
msg, err := h.replyCompare(line, repoDid, gitRelativeDir, repoName, r.Context())
if err != nil {
l.Error("failed to reply with compare link", "err", err, "line", line, "did", gitUserDid, "repo", gitRelativeDir)
// non-fatal
···
writeJSON(w, resp)
}
-
func (h *InternalHandle) replyCompare(line git.PostReceiveLine, gitUserDid string, gitRelativeDir string, repoName string, ctx context.Context) ([]string, error) {
+
func (h *InternalHandle) replyCompare(line git.PostReceiveLine, repoOwner string, gitRelativeDir string, repoName string, ctx context.Context) ([]string, error) {
l := h.l.With("handler", "replyCompare")
-
userIdent, err := idresolver.DefaultResolver().ResolveIdent(ctx, gitUserDid)
-
user := gitUserDid
+
userIdent, err := idresolver.DefaultResolver().ResolveIdent(ctx, repoOwner)
+
user := repoOwner
if err != nil {
l.Error("Failed to fetch user identity", "err", err)
// non-fatal