changed layout of repo settings page
This commit is contained in:
@@ -21,6 +21,7 @@ type repoResponse struct {
|
||||
models.Repository
|
||||
OwnerName string `json:"ownerName"`
|
||||
IsEmpty bool `json:"isEmpty"`
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
|
||||
func (h *RepoHandler) withOwnerName(repo *models.Repository) repoResponse {
|
||||
@@ -199,7 +200,10 @@ func (h *RepoHandler) Get(w http.ResponseWriter, r *http.Request) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
jsonOK(w, h.withOwnerName(repo))
|
||||
resp := h.withOwnerName(repo)
|
||||
gitdomain.SetRepoRoot(h.cfg.RepoRoot)
|
||||
resp.Size = gitdomain.RepoSize(repo.DiskPath)
|
||||
jsonOK(w, resp)
|
||||
}
|
||||
|
||||
func (h *RepoHandler) Tree(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -271,6 +271,18 @@ func Branches(repoPath string) ([]Branch, error) {
|
||||
return branches, nil
|
||||
}
|
||||
|
||||
// RepoSize returns the total byte size of the bare repo directory by walking it.
|
||||
func RepoSize(repoPath string) int64 {
|
||||
var total int64
|
||||
filepath.Walk(repoPath, func(_ string, info os.FileInfo, err error) error {
|
||||
if err == nil && !info.IsDir() {
|
||||
total += info.Size()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return total
|
||||
}
|
||||
|
||||
// SetDefaultBranch updates HEAD to point at the given branch name.
|
||||
func SetDefaultBranch(repoPath, branch string) error {
|
||||
_, err := run(repoPath, "symbolic-ref", "HEAD", "refs/heads/"+branch)
|
||||
|
||||
Reference in New Issue
Block a user