Loading juggler.go +20 −18 Original line number Diff line number Diff line Loading @@ -18,11 +18,13 @@ func NewGitDirectoryPath(rootPath string) *GitDirectoryPath { } // Walk ... func (g *GitDirectoryPath) Walk(done <-chan bool) (chan<- string, error) { func (g *GitDirectoryPath) Walk() <-chan string { pathStream := make(chan string) go func() { defer close(pathStream) if err := filepath.Walk(g.rootPath, filepath.Walk(g.rootPath, func(path string, info os.FileInfo, err error) error { if err != nil { return err Loading @@ -35,10 +37,10 @@ func (g *GitDirectoryPath) Walk(done <-chan bool) (chan<- string, error) { } pathStream <- path return nil }); err != nil { return nil, err } return pathStream, nil }) }() return pathStream } // GitDirectory returns all .git directories below a given rootPath. Loading juggler_test.go +22 −4 Original line number Diff line number Diff line Loading @@ -8,17 +8,23 @@ import ( "testing" ) func TestJugglerSearchProjects(t *testing.T) { func dirPath() (string, error) { //basePath := "/home/MUEHMER/bsmr/repositories" basePath := "repositories" usr, err := user.Current() if err != nil { t.Fatalf("user.Current() failed: %s", err) return "", err } return path.Join(usr.HomeDir, basePath), nil } dirPath := path.Join(usr.HomeDir, basePath) func TestJugglerSearchProjectsNormal(t *testing.T) { dirPath, err := dirPath() if err != nil { t.Fatalf("dirPath() failed: %s", err) } err = filepath.Walk(dirPath, func(path string, info os.FileInfo, err error) error { Loading @@ -39,6 +45,18 @@ func TestJugglerSearchProjects(t *testing.T) { } } func TestJugglerSearchProjectsStream(t *testing.T) { dirPath, err := dirPath() if err != nil { t.Fatalf("dirPath() failed: %s", err) } gdp := NewGitDirectoryPath(dirPath) for path := range gdp.Walk() { t.Logf("path: %s", path) } } func TestJugglerProcessProjectsSequential(t *testing.T) { } Loading Loading
juggler.go +20 −18 Original line number Diff line number Diff line Loading @@ -18,11 +18,13 @@ func NewGitDirectoryPath(rootPath string) *GitDirectoryPath { } // Walk ... func (g *GitDirectoryPath) Walk(done <-chan bool) (chan<- string, error) { func (g *GitDirectoryPath) Walk() <-chan string { pathStream := make(chan string) go func() { defer close(pathStream) if err := filepath.Walk(g.rootPath, filepath.Walk(g.rootPath, func(path string, info os.FileInfo, err error) error { if err != nil { return err Loading @@ -35,10 +37,10 @@ func (g *GitDirectoryPath) Walk(done <-chan bool) (chan<- string, error) { } pathStream <- path return nil }); err != nil { return nil, err } return pathStream, nil }) }() return pathStream } // GitDirectory returns all .git directories below a given rootPath. Loading
juggler_test.go +22 −4 Original line number Diff line number Diff line Loading @@ -8,17 +8,23 @@ import ( "testing" ) func TestJugglerSearchProjects(t *testing.T) { func dirPath() (string, error) { //basePath := "/home/MUEHMER/bsmr/repositories" basePath := "repositories" usr, err := user.Current() if err != nil { t.Fatalf("user.Current() failed: %s", err) return "", err } return path.Join(usr.HomeDir, basePath), nil } dirPath := path.Join(usr.HomeDir, basePath) func TestJugglerSearchProjectsNormal(t *testing.T) { dirPath, err := dirPath() if err != nil { t.Fatalf("dirPath() failed: %s", err) } err = filepath.Walk(dirPath, func(path string, info os.FileInfo, err error) error { Loading @@ -39,6 +45,18 @@ func TestJugglerSearchProjects(t *testing.T) { } } func TestJugglerSearchProjectsStream(t *testing.T) { dirPath, err := dirPath() if err != nil { t.Fatalf("dirPath() failed: %s", err) } gdp := NewGitDirectoryPath(dirPath) for path := range gdp.Walk() { t.Logf("path: %s", path) } } func TestJugglerProcessProjectsSequential(t *testing.T) { } Loading