forked from hound-search/hound
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes hound-search#7: Make Hound Go Gettable.
- Loading branch information
Showing
84 changed files
with
1,178 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
pkg | ||
bin | ||
hound.sublime-workspace | ||
data | ||
.vagrant | ||
pub/index.html | ||
pub/excluded_files.html | ||
build | ||
config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,13 @@ | ||
BINS = bin/houndd bin/hound | ||
HOST = localhost:6080 | ||
|
||
TESTS = ansi \ | ||
hound/codesearch/index \ | ||
hound/codesearch/regexp \ | ||
hound/client \ | ||
hound/index \ | ||
hound/vcs \ | ||
hound/config | ||
ALL: ui/bindata.go | ||
|
||
ALL: $(BINS) | ||
build/bin/go-bindata: | ||
GOPATH=`pwd`/build go get github.com/jteeuwen/go-bindata/... | ||
|
||
bin/houndd : $(wildcard src/hound/**/*) | ||
GOPATH=`pwd` go build -o $@ src/hound/cmds/houndd/main.go | ||
ui/bindata.go: build/bin/go-bindata $(wildcard ui/assets/**/*) | ||
rsync -r --exclude '*.js' ui/assets/* build/ui | ||
jsx --no-cache-dir ui/assets/js build/ui/js | ||
$< -o $@ -pkg ui -prefix build/ui -nomemcopy build/ui/... | ||
|
||
bin/hound : $(wildcard src/hound/**/*) | ||
GOPATH=`pwd` go build -o $@ \ | ||
-ldflags "-X main.defaultHost $(HOST)" \ | ||
src/hound/cmds/hound/*.go | ||
|
||
test: | ||
GOPATH=`pwd` go test $(TESTS) | ||
|
||
clean: | ||
rm -f $(BINS) | ||
rm -f build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package client | ||
|
||
import ( | ||
"hound/index" | ||
"github.com/etsy/hound/index" | ||
) | ||
|
||
type Block struct { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package client | ||
|
||
import ( | ||
"hound/index" | ||
"github.com/etsy/hound/index" | ||
"testing" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"flag" | ||
"github.com/etsy/hound/api" | ||
"github.com/etsy/hound/config" | ||
"github.com/etsy/hound/searcher" | ||
"github.com/etsy/hound/ui" | ||
"log" | ||
"net/http" | ||
"os" | ||
"runtime" | ||
"strings" | ||
) | ||
|
||
var ( | ||
info_log *log.Logger | ||
error_log *log.Logger | ||
) | ||
|
||
func makeSearchers(cfg *config.Config) (map[string]*searcher.Searcher, bool, error) { | ||
// Ensure we have a dbpath | ||
if _, err := os.Stat(cfg.DbPath); err != nil { | ||
if err := os.MkdirAll(cfg.DbPath, os.ModePerm); err != nil { | ||
return nil, false, err | ||
} | ||
} | ||
|
||
searchers, errs, err := searcher.MakeAll(cfg) | ||
if err != nil { | ||
return nil, false, err | ||
} | ||
|
||
if len(errs) > 0 { | ||
// NOTE: This mutates the original config so the repos | ||
// are not even seen by other code paths. | ||
for name, _ := range errs { | ||
delete(cfg.Repos, name) | ||
} | ||
|
||
return searchers, false, nil | ||
} | ||
|
||
return searchers, true, nil | ||
} | ||
|
||
func makeTemplateData(cfg *config.Config) (interface{}, error) { | ||
var data struct { | ||
ReposAsJson string | ||
} | ||
|
||
res := map[string]*config.Repo{} | ||
for name, repo := range cfg.Repos { | ||
res[strings.ToLower(name)] = repo | ||
} | ||
|
||
b, err := json.Marshal(res) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
data.ReposAsJson = string(b) | ||
return &data, nil | ||
} | ||
|
||
func runHttp( | ||
addr string, | ||
dev bool, | ||
cfg *config.Config, | ||
idx map[string]*searcher.Searcher) error { | ||
m := http.DefaultServeMux | ||
|
||
h, err := ui.Content(dev, cfg) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
m.Handle("/", h) | ||
api.Setup(m, idx) | ||
return http.ListenAndServe(addr, m) | ||
} | ||
|
||
func main() { | ||
runtime.GOMAXPROCS(runtime.NumCPU()) | ||
info_log = log.New(os.Stdout, "", log.LstdFlags) | ||
error_log = log.New(os.Stderr, "", log.LstdFlags) | ||
|
||
flagConf := flag.String("conf", "config.json", "") | ||
flagAddr := flag.String("addr", ":6080", "") | ||
flagDev := flag.Bool("dev", false, "") | ||
|
||
flag.Parse() | ||
|
||
var cfg config.Config | ||
if err := cfg.LoadFromFile(*flagConf); err != nil { | ||
panic(err) | ||
} | ||
|
||
idx, ok, err := makeSearchers(&cfg) | ||
if err != nil { | ||
log.Panic(err) | ||
} | ||
if !ok { | ||
info_log.Println("Some repos failed to index, see output above") | ||
} else { | ||
info_log.Println("All indexes built!") | ||
} | ||
|
||
host := *flagAddr | ||
if strings.HasPrefix(host, ":") { | ||
host = "localhost" + host | ||
} | ||
|
||
info_log.Printf("running server at http://%s...\n", host) | ||
|
||
if err := runHttp(*flagAddr, *flagDev, &cfg, idx); err != nil { | ||
panic(err) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.