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	git "github.com/libgit2/git2go/v34"
 9)
10
11// RepoFile represents information for a single file/blob.
12type RepoFile struct {
13	Path string // Slash separated path
14	Type git.ObjectType
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.Type == git.ObjectTree
27}
28
29func (f *RepoFile) IsSubmodule() bool {
30	return f.Type == git.ObjectCommit
31}
32
33func (f *RepoFile) PathElements() []string {
34	return strings.SplitN(f.Path, "/", -1)
35}