depp

No frills static page generator for Git repositories

git clone https://git.8pit.net/depp.git

 1package gitweb
 2
 3import (
 4	"path"
 5	"path/filepath"
 6	"strings"
 7
 8	"github.com/go-git/go-git/v5/plumbing/filemode"
 9)
10
11// RepoFile represents information for a single file/blob.
12type RepoFile struct {
13	mode filemode.FileMode
14	Path string // Slash separated path
15}
16
17func (f *RepoFile) Name() string {
18	return path.Base(f.Path)
19}
20
21func (f *RepoFile) FilePath() string {
22	return filepath.FromSlash(f.Path)
23}
24
25func (f *RepoFile) IsDir() bool {
26	return f.mode == filemode.Dir
27}
28
29func (f *RepoFile) IsSubmodule() bool {
30	return f.mode == filemode.Submodule
31}
32
33func (f *RepoFile) PathElements() []string {
34	return strings.SplitN(f.Path, "/", -1)
35}