blob: 5cab5e62dea2e3c730e3f0b0ec0d39c4bcaf78dd [file] [log] [blame]
package cmd
import (
"os/exec"
"strings"
"fmt"
)
// GoGetVCS implements a VCS for 'go get'.
type GoGetVCS struct {}
func (g *GoGetVCS) Get(dep *Dependency) error {
out, err := exec.Command("go", "get", dep.Name).CombinedOutput()
if err != nil {
//fmt.Print(string(out))
if strings.Contains(string(out), "no buildable Go source") {
Info("Go Get: %s", out)
return nil
}
Warn("Go Get: %s", out)
}
return err
}
func (g *GoGetVCS) Update(dep *Dependency) error {
out, err := exec.Command("go", "get", "-u", dep.Name).CombinedOutput()
if err != nil {
if strings.Contains(string(out), "no buildable Go source") {
Info("Go Get: %s", out)
return nil
}
Warn("Go Get: %s", out)
}
return err
}
func (g *GoGetVCS) Version(dep *Dependency) error {
return fmt.Errorf("%s does not have a repository/VCS set. No way to set version.", dep.Name)
}
// LastCommit always retuns "" for GoGet, which is not revision-aware.
func (g *GoGetVCS) LastCommit(dep *Dependency) (string, error) {
return "", nil
}