本文整理汇总了Golang中code/google/com/p/go/tools/go/vcs.RepoRootForImportPath函数的典型用法代码示例。如果您正苦于以下问题:Golang RepoRootForImportPath函数的具体用法?Golang RepoRootForImportPath怎么用?Golang RepoRootForImportPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RepoRootForImportPath函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: repoForTool
// repoForTool returns the correct RepoRoot for the buildTool, or an error if
// the tool is unknown.
func repoForTool() (*vcs.RepoRoot, error) {
switch *buildTool {
case "go":
return vcs.RepoRootForImportPath(*gcPath, *verbose)
case "gccgo":
return vcs.RepoRootForImportPath(gofrontendImportPath, *verbose)
default:
return nil, fmt.Errorf("unknown build tool: %s", *buildTool)
}
}
示例2: RemoteRepo
// RemoteRepo constructs a *Repo representing a remote repository.
func RemoteRepo(url, path string) (*Repo, error) {
rr, err := vcs.RepoRootForImportPath(url, *verbose)
if err != nil {
return nil, err
}
return &Repo{
Path: path,
Master: rr,
}, nil
}
示例3: VCSForImportPath
func VCSForImportPath(importPath string) (*VCS, *vcs.RepoRoot, error) {
rr, err := vcs.RepoRootForImportPath(importPath, false)
if err != nil {
return nil, nil, err
}
vcs := cmd[rr.VCS]
if vcs == nil {
return nil, nil, fmt.Errorf("%s is unsupported: %s", rr.VCS.Name, importPath)
}
return vcs, rr, nil
}
示例4: main
func main() {
flag.Parse()
if *importPathFlag != "" {
repoRoot, err := vcs.RepoRootForImportPath(*importPathFlag, false)
if err == nil {
fmt.Fprintln(os.Stdout, toJson(repoRoot))
os.Exit(0)
} else {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}
}
示例5: buildSubrepo
// buildSubrepo fetches the given package, updates it to the specified hash,
// and runs 'go test -short pkg/...'. It returns the build log and any error.
func (b *Builder) buildSubrepo(goRoot, goPath, pkg, hash string) (string, error) {
goTool := filepath.Join(goRoot, "bin", "go") + exeExt
env := append(b.envv(), "GOROOT="+goRoot, "GOPATH="+goPath)
// add $GOROOT/bin and $GOPATH/bin to PATH
for i, e := range env {
const p = "PATH="
if !strings.HasPrefix(e, p) {
continue
}
sep := string(os.PathListSeparator)
env[i] = p + filepath.Join(goRoot, "bin") + sep + filepath.Join(goPath, "bin") + sep + e[len(p):]
}
// fetch package and dependencies
log, ok, err := runLog(*cmdTimeout, env, goPath, goTool, "get", "-d", pkg+"/...")
if err == nil && !ok {
err = fmt.Errorf("go exited with status 1")
}
if err != nil {
return log, err
}
// hg update to the specified hash
pkgmaster, err := vcs.RepoRootForImportPath(pkg, *verbose)
if err != nil {
return "", fmt.Errorf("Error finding subrepo (%s): %s", pkg, err)
}
repo := &Repo{
Path: filepath.Join(goPath, "src", pkg),
Master: pkgmaster,
}
if err := repo.UpdateTo(hash); err != nil {
return "", err
}
// test the package
log, ok, err = runLog(*buildTimeout, env, goPath, goTool, "test", "-short", pkg+"/...")
if err == nil && !ok {
err = fmt.Errorf("go exited with status 1")
}
return log, err
}
示例6: commitWatcher
// commitWatcher polls hg for new commits and tells the dashboard about them.
func commitWatcher(goroot *Repo) {
if *commitInterval == 0 {
log.Printf("commitInterval is %s, disabling commitWatcher", *commitInterval)
return
}
// Create builder just to get master key.
b, err := NewBuilder(goroot, "mercurial-commit")
if err != nil {
log.Fatal(err)
}
key := b.key
benchMutex.RLock()
for {
if *verbose {
log.Printf("poll...")
}
// Main Go repository.
commitPoll(goroot, "", key)
// Go sub-repositories.
for _, pkg := range dashboardPackages("subrepo") {
pkgmaster, err := vcs.RepoRootForImportPath(pkg, *verbose)
if err != nil {
log.Printf("Error finding subrepo (%s): %s", pkg, err)
continue
}
pkgroot := &Repo{
Path: filepath.Join(*buildroot, pkg),
Master: pkgmaster,
}
commitPoll(pkgroot, pkg, key)
}
benchMutex.RUnlock()
if *verbose {
log.Printf("sleep...")
}
time.Sleep(*commitInterval)
benchMutex.RLock()
}
}
示例7: buildSubrepo
// buildSubrepo fetches the given package, updates it to the specified hash,
// and runs 'go test -short pkg/...'. It returns the build log and any error.
func (b *Builder) buildSubrepo(goRoot, goPath, pkg, hash string) (string, error) {
goTool := filepath.Join(goRoot, "bin", "go") + exeExt
env := append(b.envv(), "GOROOT="+goRoot, "GOPATH="+goPath)
// add $GOROOT/bin and $GOPATH/bin to PATH
for i, e := range env {
const p = "PATH="
if !strings.HasPrefix(e, p) {
continue
}
sep := string(os.PathListSeparator)
env[i] = p + filepath.Join(goRoot, "bin") + sep + filepath.Join(goPath, "bin") + sep + e[len(p):]
}
// fetch package and dependencies
var outbuf bytes.Buffer
err := run(exec.Command(goTool, "get", "-d", pkg+"/..."), runEnv(env), allOutput(&outbuf), runDir(goPath))
if err != nil {
return outbuf.String(), err
}
outbuf.Reset()
// hg update to the specified hash
pkgmaster, err := vcs.RepoRootForImportPath(pkg, *verbose)
if err != nil {
return "", fmt.Errorf("Error finding subrepo (%s): %s", pkg, err)
}
repo := &Repo{
Path: filepath.Join(goPath, "src", pkg),
Master: pkgmaster,
}
if err := repo.UpdateTo(hash); err != nil {
return "", err
}
// test the package
err = run(exec.Command(goTool, "test", "-short", pkg+"/..."),
runTimeout(*buildTimeout), runEnv(env), allOutput(&outbuf), runDir(goPath))
return outbuf.String(), err
}
示例8: repoForDep
func repoForDep(dep *parser.Dependency) (*vcs.RepoRoot, error) {
if dep.URL != "" {
return RepoRootForImportPathWithURLOverride(dep.Pkg, dep.URL)
}
return vcs.RepoRootForImportPath(dep.Pkg, true)
}
示例9: parseAndInstall
//.........这里部分代码省略.........
}
}
// if rev is not given, record current rev in path
if dep.Rev == "" {
rev, err := g.currentRev(repo.VCS.Cmd, tmpPkgPath)
if err != nil {
return err
}
dep.Rev = rev
}
lockedDeps[dep.Pkg] = dep
// checkout specified rev
err = g.checkout(repo.VCS.Cmd, tmpPkgPath, dep.Rev)
if err != nil {
return err
}
}
for _, dep := range deps {
g.stdout.Write([]byte(colors.OK + "=> Fetching dependencies for " + dep.Pkg + "..." + colors.Reset + "\n"))
repo := repos[dep.Pkg]
tmpPkgPath := path.Join(tmpSrcPath, repo.Root)
// fetch sub-dependencies
subdeps, err := g.goGet(tmpPkgPath, tmpGoPath)
if err != nil {
return err
}
for _, subdep := range subdeps {
subdepRepo, err := vcs.RepoRootForImportPath(subdep, true)
if err != nil {
return err
}
subdepPkgPath := path.Join(tmpSrcPath, subdepRepo.Root)
rev, err := g.currentRev(subdepRepo.VCS.Cmd, subdepPkgPath)
if err != nil {
return err
}
err = g.checkout(subdepRepo.VCS.Cmd, subdepPkgPath, rev)
if err != nil {
return err
}
repos[subdep] = subdepRepo
lockedDeps[subdep] = &parser.Dependency{Pkg: subdep, Rev: rev}
}
}
for _, dep := range lockedDeps {
g.stdout.Write([]byte(colors.OK + "=> Installing " + dep.Pkg + "..." + colors.Reset + "\n"))
repo := repos[dep.Pkg]
pkgPath := path.Join(srcPath, repo.Root)
tmpPkgPath := path.Join(tmpSrcPath, repo.Root)
err = os.MkdirAll(path.Join(pkgPath, ".."), 0775)
if err != nil {
return err
}