-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
// Copyright 2026 Shota FUJI <pockawoooh@gmail.com>
// SPDX-License-Identifier: MIT
package repo
import (
"log"
"net/http"
"github.com/pocka/legit/git"
"github.com/pocka/legit/pages/errors"
"github.com/pocka/legit/templates"
)
func (repo *Repo) refs(w http.ResponseWriter, r *http.Request) {
tags, err := git.Tags(repo.r)
if err != nil {
// Non-fatal, we *should* have at least one branch to show.
log.Println(err)
}
branches, err := git.Branches(repo.r)
if err != nil {
errors.WriteInternalServerError(repo.core, w, r)
log.Println(err)
return
}
mainBranch, err := git.FindMainBranch(repo.r, repo.core.Config.Repo.MainBranch)
if err != nil {
errors.WriteInternalServerError(repo.core, w, r)
log.Println(err)
return
}
data := templates.RepoRefsData{
Config: repo.core.Config,
Meta: templates.RepositoryMeta{
DisplayName: repo.core.RepositoryName(repo.dirname),
DirName: repo.dirname,
Description: git.GitwebDescription(repo.r),
Ref: mainBranch,
},
Tags: tags,
Branches: branches,
}
if err := repo.core.Template().ExecuteTemplate(w, "repo-refs", data); err != nil {
log.Println(err)
return
}
}