fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

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

Merge remote-tracking branch 'gerrit/master'

Change-Id: Ib52439f381be7db3dec5b4232c4b628838af80b2

+38 -17
+7 -15
indexbuilder.go
··· 226 226 return err 227 227 } 228 228 229 - for _, subrepo := range desc.SubRepoMap { 230 - branchEqual := len(subrepo.Branches) == len(desc.Branches) 231 - if branchEqual { 232 - for i, b := range subrepo.Branches { 233 - branchEqual = branchEqual && (b.Name == desc.Branches[i].Name) 234 - } 235 - } 236 - } 237 - 238 229 if len(desc.Branches) > 64 { 239 230 return fmt.Errorf("too many branches") 240 231 } 241 232 242 233 b.repo = *desc 243 - repoCopy := *desc 244 - repoCopy.SubRepoMap = nil 245 234 246 - if b.repo.SubRepoMap == nil { 247 - b.repo.SubRepoMap = map[string]*Repository{} 235 + // copy subrepomap without root 236 + b.repo.SubRepoMap = map[string]*Repository{} 237 + for k, v := range desc.SubRepoMap { 238 + if k != "" { 239 + b.repo.SubRepoMap[k] = v 240 + } 248 241 } 249 - b.repo.SubRepoMap[""] = &repoCopy 250 242 251 243 b.populateSubRepoIndices() 252 244 return nil ··· 336 328 if b.subRepoIndices != nil { 337 329 return 338 330 } 339 - var paths []string 331 + paths := []string{""} 340 332 for k := range b.repo.SubRepoMap { 341 333 paths = append(paths, k) 342 334 }
+5 -2
read.go
··· 255 255 256 256 d.subRepoPaths = make([][]string, 0, len(d.repoMetaData)) 257 257 for i := 0; i < len(d.repoMetaData); i++ { 258 - keys := make([]string, 0, len(d.repoMetaData[i].SubRepoMap)) 258 + keys := make([]string, 0, len(d.repoMetaData[i].SubRepoMap)+1) 259 + keys = append(keys, "") 259 260 for k := range d.repoMetaData[i].SubRepoMap { 260 - keys = append(keys, k) 261 + if k != "" { 262 + keys = append(keys, k) 263 + } 261 264 } 262 265 sort.Strings(keys) 263 266 d.subRepoPaths = append(d.subRepoPaths, keys)
+3
web/e2e_test.go
··· 129 129 "/search?q=magic": { 130 130 `value=magic`, 131 131 }, 132 + "/robots.txt": { 133 + "disallow: /search", 134 + }, 132 135 } { 133 136 checkNeedles(t, ts, req, needles) 134 137 }
+19
web/server.go
··· 111 111 result *template.Template 112 112 print *template.Template 113 113 about *template.Template 114 + robots *template.Template 114 115 115 116 startTime time.Time 116 117 ··· 152 153 "search": &s.search, 153 154 "repolist": &s.repolist, 154 155 "about": &s.about, 156 + "robots": &s.robots, 155 157 } { 156 158 *v = s.Top.Lookup(k) 157 159 if *v == nil { ··· 165 167 mux := http.NewServeMux() 166 168 167 169 if s.HTML { 170 + mux.HandleFunc("/robots.txt", s.serveRobots) 168 171 mux.HandleFunc("/search", s.serveSearch) 169 172 mux.HandleFunc("/", s.serveSearchBox) 170 173 mux.HandleFunc("/about", s.serveAbout) ··· 403 406 404 407 func (s *Server) serveAbout(w http.ResponseWriter, r *http.Request) { 405 408 if err := s.serveAboutErr(w, r); err != nil { 409 + http.Error(w, err.Error(), http.StatusTeapot) 410 + } 411 + } 412 + 413 + func (s *Server) serveRobotsErr(w http.ResponseWriter, r *http.Request) error { 414 + data := struct{}{} 415 + var buf bytes.Buffer 416 + if err := s.robots.Execute(&buf, &data); err != nil { 417 + return err 418 + } 419 + w.Write(buf.Bytes()) 420 + return nil 421 + } 422 + 423 + func (s *Server) serveRobots(w http.ResponseWriter, r *http.Request) { 424 + if err := s.serveRobotsErr(w, r); err != nil { 406 425 http.Error(w, err.Error(), http.StatusTeapot) 407 426 } 408 427 }
+4
web/templates.go
··· 393 393 </div> 394 394 </nav> 395 395 `, 396 + "robots": ` 397 + user-agent: * 398 + disallow: /search 399 + `, 396 400 } 397 401 398 402 func init() {