Skip to content

Commit 4a14787

Browse files
committed
Support multiple repos as "-p" parameters
Signed-off-by: Javi Fontan <[email protected]>
1 parent bb73108 commit 4a14787

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

cmd/gitquery/query_base.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
type cmdQueryBase struct {
1818
cmd
1919

20-
Path string `short:"p" long:"path" description:"Path where the git repository is located"`
20+
Path []string `short:"p" long:"path" description:"Path where the git repository is located"`
2121

2222
engine *sqle.Engine
2323
name string
@@ -31,15 +31,20 @@ func (c *cmdQueryBase) buildDatabase() error {
3131
c.print("opening %q repository...\n", c.Path)
3232

3333
var err error
34-
r, err := gogit.PlainOpen(c.Path)
35-
if err != nil {
36-
return err
37-
}
3834

3935
pool := gitquery.NewRepositoryPool()
40-
pool.Add(c.Path, r)
4136

42-
c.name = filepath.Base(filepath.Join(c.Path, ".."))
37+
for _, path := range c.Path {
38+
r, err := gogit.PlainOpen(path)
39+
if err != nil {
40+
return err
41+
}
42+
43+
pool.Add(path, r)
44+
45+
c.name = filepath.Base(filepath.Join(path, ".."))
46+
}
47+
4348
c.engine.AddDatabase(gitquery.NewDatabase(c.name, &pool))
4449
return err
4550
}

0 commit comments

Comments
 (0)