-
Notifications
You must be signed in to change notification settings - Fork 2
/
directory.go
39 lines (35 loc) · 1.04 KB
/
directory.go
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
package main
import (
"github.com/shurcooL/home/component"
"github.com/shurcooL/home/internal/code"
"github.com/shurcooL/home/internal/route"
"github.com/shurcooL/htmlg"
"github.com/shurcooL/octicon"
)
// directoryGitPathspec returns a git pathspec that
// constraints git operations to only directory d.
func directoryGitPathspec(d *code.Directory) string {
if d.ImportPath == d.RepoRoot {
return ":(glob)*"
}
return ":(glob)" + d.ImportPath[len(d.RepoRoot)+len("/"):] + "/*"
}
// pathWithinRepo returns the path of directory d
// relative to repository root, or empty string if at root.
func pathWithinRepo(d *code.Directory) string {
if d.ImportPath == d.RepoRoot {
return ""
}
return d.ImportPath[len(d.RepoRoot)+len("/"):]
}
func directoryTabnav(selected component.RepositoryTab, pkgPath string) htmlg.Component {
return component.TabNav{
Tabs: []component.Tab{
{
Content: iconText{Icon: octicon.History, Text: "History"},
URL: route.PkgHistory(pkgPath),
Selected: selected == component.HistoryTab,
},
},
}
}