-
Notifications
You must be signed in to change notification settings - Fork 127
cmd/gitbase: load siva files and git indistinctly #416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/gitbase: load siva files and git indistinctly #416
Conversation
repository_pool.go
Outdated
@@ -262,6 +276,7 @@ func (p *RepositoryPool) addSivaFile(root, path string, f os.FileInfo) { | |||
|
|||
if strings.HasSuffix(f.Name(), ".siva") { | |||
path := filepath.Join(path, f.Name()) | |||
fmt.Println(path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
repository_pool.go
Outdated
@@ -182,6 +183,7 @@ func (p *RepositoryPool) AddGit(path string) (string, error) { | |||
// AddGitWithID checks if a git repository can be opened and adds it to the | |||
// pool. ID should be specified. | |||
func (p *RepositoryPool) AddGitWithID(id, path string) (string, error) { | |||
fmt.Println(id, path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
cmd/gitbase/command/server.go
Outdated
} | ||
|
||
return nil | ||
for _, file := range files { | ||
if file.Name() == ".git" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about bare repositories?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
449e541
to
4b2ead1
Compare
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
4b2ead1
to
9dcd907
Compare
I love this! Great for user-friendliness. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should change documentation too @mcarmonaa
@ajnavarro sure, I'll do it too. Other than that, do you think I should remove all the code related to load repositories from |
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
|
path_utils_test.go
Outdated
require.Exactly(t, test.expected, files) | ||
}) | ||
} | ||
} | ||
|
||
func TestPatternPrefixDepth(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you delete that test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the function was tested here is not needed now so I removed it.
repository_pool.go
Outdated
// that is, has the .siva extension | ||
func (p *RepositoryPool) AddSivaFile(path string) error { | ||
file := filepath.Base(path) | ||
if !strings.HasSuffix(file, ".siva") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would separate the logic related to check if the path is from a siva file, and add a siva repository to the repository pool. Per example, as we have a isGitRepo
function, we should have a isSivaFile
function to check if we can add that file to the pool.
return err | ||
} | ||
|
||
if info.IsDir() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could split these two cases to their own functions, and maybe then simplify some of the conditions with return early clauses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've placed the logic related to add a git repository in its own method, but I can't see how to simplify the conditions
5e13a54
to
ed911c2
Compare
…sitoriy when is added Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
ed911c2
to
adb1156
Compare
Closes #414
The new usage looks like:
Changes
-d, --directories
so there's no more--git
or--siva
--depth
you can specify how many levels from the specified directory must be checked.--no-git
and--no-siva
:So if we have a directory structure:
. ├── a.siva ├── b.siva ├── repo-a └── some-dir ├── c.siva └── repo-b
gitbase server -d=d1
-> will loada.siva
,b.siva
,repo-a
,repo-b
,c.siva
gitbase server -d=d1 --no-git
-> will loada.siva
,b.siva
,c.siva
gitbase server -d=d1 --no-siva
-> will loadrepo-a
,repo-b
gitbase server -d=d1 --depth=1
-> will loada.siva
,b.siva
,repo-a
All the variants combining
--no-git
and--no-siva
flags with--depth
are allowed and work too.On the other hand, there is some useless code left in
repository_pool.go
about load directories, should I remove it?@src-d/data-retrieval WDYT?