Skip to content

Commit

Permalink
Update add.go for fixing the test failed by using submodules.
Browse files Browse the repository at this point in the history
If the repository is submodule, `.git` will be a file to indicate `.git` directory.
  • Loading branch information
tamada committed Mar 8, 2019
1 parent 9f69a6b commit 5c489a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ test:

update: setup
dep ensure
git submodule update --init

lint: setup
go vet $$(go list ./... | grep -v vendor)
Expand Down
10 changes: 3 additions & 7 deletions add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@ func (add *AddCommand) isExistAndGitRepository(absPath string, path string) erro
return fmt.Errorf("%s: not directory", path)
}
fmode, err = os.Stat(filepath.Join(absPath, ".git"))
fmt.Printf(filepath.Join(absPath, ".git"))
if err != nil || !fmode.IsDir() {
if err != nil {
fmt.Printf("Error: %s\n", err.Error())
}
fmt.Printf("%s: not git repository (%v)", absPath, fmode.Mode())
return fmt.Errorf("%s: not git repository (%v)", path, fmode.Mode())
// If the repository of path is submodule, `.git` will be a file to indicate the `.git` directory.
if os.IsNotExist(err) {
return fmt.Errorf("%s: not git repository", path)
}
return nil
}
Expand Down

0 comments on commit 5c489a8

Please sign in to comment.