From 04e49c1b8e5c120f2a5170f26b943acacf81a818 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Tue, 9 Sep 2025 14:47:17 +0100 Subject: [PATCH] appview: restore old behavior when non-default branches are pushed Change-Id: okpttztkvunpsxqwtkntlryuszlovqpo Signed-off-by: oppiliappan --- appview/repo/index.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/appview/repo/index.go b/appview/repo/index.go index c8b9557e..aafb8e1a 100644 --- a/appview/repo/index.go +++ b/appview/repo/index.go @@ -63,11 +63,11 @@ func (rp *Repo) RepoIndex(w http.ResponseWriter, r *http.Request) { RepoInfo: repoInfo, }) return - } else { - rp.pages.Error503(w) - log.Println("failed to build index response", err) - return } + + rp.pages.Error503(w) + log.Println("failed to build index response", err) + return } tagMap := make(map[string][]string) @@ -256,20 +256,17 @@ func (rp *Repo) buildIndexResponse(ctx context.Context, xrpcc *indigoxrpc.Client } // if no ref specified, use default branch or first available - if ref == "" && len(branchesResp.Branches) > 0 { + if ref == "" { for _, branch := range branchesResp.Branches { if branch.IsDefault { ref = branch.Name break } } - if ref == "" { - ref = branchesResp.Branches[0].Name - } } - // check if repo is empty - if len(branchesResp.Branches) == 0 { + // if ref is still empty, this means the default branch is not set + if ref == "" { return &types.RepoIndexResponse{ IsEmpty: true, Branches: branchesResp.Branches, -- 2.43.0