mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 11:52:10 +00:00
show readme.md
This commit is contained in:
parent
26f9962b6e
commit
5bc2a1a6f9
4 changed files with 101 additions and 17 deletions
|
@ -5,6 +5,7 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -22,12 +23,25 @@ type Commit struct {
|
|||
Message string
|
||||
}
|
||||
|
||||
var (
|
||||
ErrRepoFileNotLoaded = fmt.Errorf("repo file not loaded")
|
||||
)
|
||||
|
||||
type RepoFile struct {
|
||||
*git.TreeEntry
|
||||
Path string
|
||||
Message string
|
||||
Created time.Time
|
||||
Size int64
|
||||
Repo *git.Repository
|
||||
}
|
||||
|
||||
func (file *RepoFile) LookupBlob() (*git.Blob, error) {
|
||||
if file.Repo == nil {
|
||||
return nil, ErrRepoFileNotLoaded
|
||||
}
|
||||
|
||||
return file.Repo.LookupBlob(file.Id)
|
||||
}
|
||||
|
||||
func GetBranches(userName, reposName string) ([]string, error) {
|
||||
|
@ -80,6 +94,7 @@ func GetReposFiles(userName, reposName, branchName, rpath string) ([]*RepoFile,
|
|||
lastCommit.Message(),
|
||||
lastCommit.Committer.When,
|
||||
size,
|
||||
repo,
|
||||
})
|
||||
case git.FileModeTree:
|
||||
repodirs = append(repodirs, &RepoFile{
|
||||
|
@ -88,6 +103,7 @@ func GetReposFiles(userName, reposName, branchName, rpath string) ([]*RepoFile,
|
|||
lastCommit.Message(),
|
||||
lastCommit.Committer.When,
|
||||
size,
|
||||
repo,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue