web frontend for git (tangled's grandpa)
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

config: add repo.ignore

+60 -10
+1
config/config.go
··· 12 12 ScanPath string `yaml:"scanPath"` 13 13 Readme []string `yaml:"readme"` 14 14 MainBranch []string `yaml:"mainBranch"` 15 + Ignore []string `yaml:"ignore,omitempty"` 15 16 } `yaml:"repo"` 16 17 Dirs struct { 17 18 Templates string `yaml:"templates"`
+4
readme
··· 39 39 mainBranch: 40 40 - master 41 41 - main 42 + ignore: 43 + - foo 44 + - bar 42 45 dirs: 43 46 templates: ./templates 44 47 static: ./static ··· 56 59 traverse subdirs yet. 57 60 • repo.readme: readme files to look for. Markdown isn't rendered. 58 61 • repo.mainBranch: main branch names to look for. 62 + • repo.ignore: repos to ignore. 59 63 • server.name: used for go-import meta tags and clone URLs. 60 64 61 65
+29 -10
routes/routes.go
··· 35 35 infos := []info{} 36 36 37 37 for _, dir := range dirs { 38 + if d.isIgnored(dir.Name()) { 39 + continue 40 + } 41 + 38 42 path := filepath.Join(d.c.Repo.ScanPath, dir.Name()) 39 43 gr, err := git.Open(path, "") 40 44 if err != nil { ··· 77 81 78 82 func (d *deps) RepoIndex(w http.ResponseWriter, r *http.Request) { 79 83 name := flow.Param(r.Context(), "name") 84 + if d.isIgnored(name) { 85 + d.Write404(w) 86 + return 87 + } 80 88 name = filepath.Clean(name) 81 89 path := filepath.Join(d.c.Repo.ScanPath, name) 90 + 82 91 gr, err := git.Open(path, "") 83 92 if err != nil { 84 93 d.Write404(w) ··· 136 145 137 146 func (d *deps) RepoTree(w http.ResponseWriter, r *http.Request) { 138 147 name := flow.Param(r.Context(), "name") 148 + if d.isIgnored(name) { 149 + d.Write404(w) 150 + return 151 + } 139 152 treePath := flow.Param(r.Context(), "...") 140 153 ref := flow.Param(r.Context(), "ref") 141 154 ··· 166 179 167 180 func (d *deps) FileContent(w http.ResponseWriter, r *http.Request) { 168 181 name := flow.Param(r.Context(), "name") 182 + if d.isIgnored(name) { 183 + d.Write404(w) 184 + return 185 + } 169 186 treePath := flow.Param(r.Context(), "...") 170 187 ref := flow.Param(r.Context(), "ref") 171 188 ··· 190 207 191 208 func (d *deps) Log(w http.ResponseWriter, r *http.Request) { 192 209 name := flow.Param(r.Context(), "name") 210 + if d.isIgnored(name) { 211 + d.Write404(w) 212 + return 213 + } 193 214 ref := flow.Param(r.Context(), "ref") 194 215 195 216 path := filepath.Join(d.c.Repo.ScanPath, name) ··· 224 245 225 246 func (d *deps) Diff(w http.ResponseWriter, r *http.Request) { 226 247 name := flow.Param(r.Context(), "name") 248 + if d.isIgnored(name) { 249 + d.Write404(w) 250 + return 251 + } 227 252 ref := flow.Param(r.Context(), "ref") 228 253 229 254 path := filepath.Join(d.c.Repo.ScanPath, name) ··· 261 286 262 287 func (d *deps) Refs(w http.ResponseWriter, r *http.Request) { 263 288 name := flow.Param(r.Context(), "name") 289 + if d.isIgnored(name) { 290 + d.Write404(w) 291 + return 292 + } 264 293 265 294 path := filepath.Join(d.c.Repo.ScanPath, name) 266 295 gr, err := git.Open(path, "") ··· 305 334 306 335 http.ServeFile(w, r, f) 307 336 } 308 - 309 - func getDescription(path string) (desc string) { 310 - db, err := os.ReadFile(filepath.Join(path, "description")) 311 - if err == nil { 312 - desc = string(db) 313 - } else { 314 - desc = "" 315 - } 316 - return 317 - }
+26
routes/util.go
··· 1 + package routes 2 + 3 + import ( 4 + "os" 5 + "path/filepath" 6 + ) 7 + 8 + func getDescription(path string) (desc string) { 9 + db, err := os.ReadFile(filepath.Join(path, "description")) 10 + if err == nil { 11 + desc = string(db) 12 + } else { 13 + desc = "" 14 + } 15 + return 16 + } 17 + 18 + func (d *deps) isIgnored(name string) bool { 19 + for _, i := range d.c.Repo.Ignore { 20 + if name == i { 21 + return true 22 + } 23 + } 24 + 25 + return false 26 + }