-
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.
- Loading branch information
1 parent
8a03bcf
commit 17add77
Showing
6 changed files
with
107 additions
and
4 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
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,66 @@ | ||
package discover | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
"os" | ||
"path" | ||
) | ||
|
||
// Gvt is a discoverer for gvt Go package manager. | ||
type Gvt struct{} | ||
|
||
// Name returns name of Gvt discoverer. | ||
func (g Gvt) Name() string { | ||
return "gvt" | ||
} | ||
|
||
// InUse checks whether project is using gvt as a package manager. | ||
func (g Gvt) InUse(projectPath string) (bool, error) { | ||
_, err := os.Stat(gvtFilePath(projectPath)) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
return true, nil | ||
} | ||
|
||
func gvtFilePath(projectPath string) string { | ||
return path.Join(projectPath, "vendor", "manifest") | ||
} | ||
|
||
// Repositories discovers repositories belonging to packages imported inside a project managed by Gvt. | ||
func (g Gvt) Repositories(projectPath string) (RepoMap, error) { | ||
list, err := packageListGvt(projectPath) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
repoMap := RepoMap{} | ||
for _, p := range list.Dependencies { | ||
repoMap.add(p.Importpath) | ||
} | ||
|
||
return repoMap, nil | ||
} | ||
|
||
type gvtList struct { | ||
Dependencies []struct { | ||
Importpath string `json:"importpath"` | ||
} `json:"dependencies"` | ||
} | ||
|
||
func packageListGvt(projectPath string) (gvtList, error) { | ||
list := gvtList{} | ||
|
||
content, err := ioutil.ReadFile(gvtFilePath(projectPath)) | ||
if err != nil { | ||
return gvtList{}, err | ||
} | ||
err = json.Unmarshal(content, &list) | ||
if err != nil { | ||
return gvtList{}, err | ||
} | ||
|
||
return list, nil | ||
} |
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 @@ | ||
MISSING 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"generator": "github.com/FiloSottile/gvt", | ||
"dependencies": [ | ||
{ | ||
"importpath": "github.com/wadey/gocovmerge", | ||
"repository": "https://github.com/wadey/gocovmerge", | ||
"vcs": "git", | ||
"revision": "b5bfa59ec0adc420475f97f89b58045c721d761c", | ||
"branch": "master", | ||
"notests": true | ||
} | ||
] | ||
} |