- commit
- 8710d5e
- parent
- 87e3e38
- author
- Eric Bower
- date
- 2023-08-13 16:30:49 +0000 UTC
refactor: assume a single repo
2 files changed,
+18,
-25
+2,
-2
1@@ -31,5 +31,5 @@ jobs:
2 user: erock
3 key: ${{ secrets.PRIVATE_KEY }}
4 src: './public/*'
5- project: "git-${{ steps.vars.outputs.sha_short }}"
6- promote: "git"
7+ project: "git-pgit-${{ steps.vars.outputs.sha_short }}"
8+ promote: "git-pgit"
M
main.go
+16,
-23
1@@ -317,7 +317,7 @@ func (c *Config) writeHtml(writeData *WriteData) {
2 )
3 bail(err)
4
5- dir := filepath.Join(c.Outdir, c.RepoName, writeData.Subdir)
6+ dir := filepath.Join(c.Outdir, writeData.Subdir)
7 err = os.MkdirAll(dir, os.ModePerm)
8 bail(err)
9
10@@ -351,7 +351,7 @@ func (c *Config) writeRootSummary(data *PageData, readme template.HTML) {
11 func (c *Config) writeTree(data *PageData, tree []*TreeItem) {
12 c.writeHtml(&WriteData{
13 Filename: "index.html",
14- Subdir: filepath.Join("tree", data.RevData.RevName),
15+ Subdir: filepath.Join("tree", getShortID(data.RevData.ID)),
16 Template: "html/tree.page.tmpl",
17 Data: &TreePageData{
18 PageData: data,
19@@ -363,7 +363,7 @@ func (c *Config) writeTree(data *PageData, tree []*TreeItem) {
20 func (c *Config) writeLog(data *PageData, logs []*CommitData) {
21 c.writeHtml(&WriteData{
22 Filename: "index.html",
23- Subdir: filepath.Join("logs", data.RevData.RevName),
24+ Subdir: filepath.Join("logs", getShortID(data.RevData.ID)),
25 Template: "html/log.page.tmpl",
26 Data: &LogPageData{
27 PageData: data,
28@@ -505,27 +505,27 @@ func (c *Config) writeLogDiffs(repo *git.Repository, pageData *PageData, logs []
29 }
30
31 func (c *Config) getSummaryURL() template.URL {
32- url := fmt.Sprintf("/%s/index.html", c.RepoName)
33+ url := "/index.html"
34 return template.URL(url)
35 }
36
37 func (c *Config) getRefsURL() template.URL {
38- url := fmt.Sprintf("/%s/refs.html", c.RepoName)
39+ url := "/refs.html"
40 return template.URL(url)
41 }
42
43 func (c *Config) getTreeURL(revn string) template.URL {
44- url := fmt.Sprintf("/%s/tree/%s/index.html", c.RepoName, revn)
45+ url := fmt.Sprintf("/tree/%s/index.html", revn)
46 return template.URL(url)
47 }
48
49 func (c *Config) getLogsURL(revn string) template.URL {
50- url := fmt.Sprintf("/%s/logs/%s/index.html", c.RepoName, revn)
51+ url := fmt.Sprintf("/logs/%s/index.html", revn)
52 return template.URL(url)
53 }
54
55 func (c *Config) getCommitURL(commitID string) template.URL {
56- url := fmt.Sprintf("/%s/commits/%s.html", c.RepoName, commitID)
57+ url := fmt.Sprintf("/commits/%s.html", commitID)
58 return template.URL(url)
59 }
60
61@@ -555,7 +555,8 @@ func (c *Config) writeRepo() *BranchOutput {
62 fullRevID, err := repo.RevParse(revStr)
63 bail(err)
64
65- revName := getShortID(fullRevID)
66+ revID := getShortID(fullRevID)
67+ revName := revID
68 // if it's a reference then label it as such
69 for _, ref := range refs {
70 if revStr == git.RefShortName(ref.Refspec) || revStr == ref.Refspec {
71@@ -567,8 +568,8 @@ func (c *Config) writeRepo() *BranchOutput {
72 data := &RevData{
73 ID: fullRevID,
74 RevName: revName,
75- TreeURL: c.getTreeURL(revName),
76- LogURL: c.getLogsURL(revName),
77+ TreeURL: c.getTreeURL(revID),
78+ LogURL: c.getLogsURL(revID),
79 }
80 if first == nil {
81 first = data
82@@ -721,9 +722,7 @@ func (c *Config) writeRevision(repo *git.Repository, pageData *PageData, refs []
83 entry.When = lc.Author.When.Format(time.RFC822)
84 }
85 fpath := filepath.Join(
86- "/",
87- c.RepoName,
88- "tree",
89+ "/tree",
90 getShortID(pageData.RevData.ID),
91 "item",
92 fmt.Sprintf("%s.html", entry.Path),
93@@ -752,7 +751,6 @@ func main() {
94 var revsFlag = flag.String("revs", "HEAD", "list of revs to generate logs and tree (e.g. main,v1,c69f86f,HEAD")
95 var themeFlag = flag.String("theme", "dracula", "theme to use for site")
96 var labelFlag = flag.String("label", "", "pretty name for the subdir where we create the repo, default is last folder in --repo")
97- var assetFlag = flag.Bool("assets", false, "copy static assets to --out")
98 var cloneFlag = flag.String("clone-url", "", "git clone URL")
99 var descFlag = flag.String("desc", "", "description for repo")
100 var maxCommitsFlag = flag.Int("max-commits", 0, "maximum number of commits to generate")
101@@ -799,12 +797,8 @@ func main() {
102 }
103 config.Logger.Infof("%+v", config)
104
105- writeAssets := *assetFlag
106- if writeAssets {
107- config.copyStatic(filepath.Join(config.Outdir, "main.css"), mainCss)
108- config.copyStatic(filepath.Join(config.Outdir, "syntax.css"), syntaxCss)
109- return
110- }
111+ config.copyStatic(filepath.Join(config.Outdir, "main.css"), mainCss)
112+ config.copyStatic(filepath.Join(config.Outdir, "syntax.css"), syntaxCss)
113
114 if len(revs) == 0 {
115 bail(fmt.Errorf("you must provide --revs"))
116@@ -812,7 +806,6 @@ func main() {
117
118 config.writeRepo()
119
120- prefixPath := filepath.Join("/", config.RepoName)
121- url := filepath.Join(prefixPath, "index.html")
122+ url := filepath.Join("/", "index.html")
123 config.Logger.Info(url)
124 }