예제 #1
0
파일: abot.go 프로젝트: itsabot/abot
func updatePlugins() {
	l := log.New("")
	l.SetFlags(0)
	l.SetDebug(os.Getenv("ABOT_DEBUG") == "true")

	if err := core.LoadConf(); err != nil {
		l.Fatal(err)
	}
	plugins := buildPluginFile(l)

	l.Info("Updating plugins...")
	for path, version := range plugins.Dependencies {
		if version != "*" {
			continue
		}
		l.Infof("Updating %s...\n", path)
		outC, err := exec.
			Command("/bin/sh", "-c", "go get -u "+path).
			CombinedOutput()
		if err != nil {
			l.Info(string(outC))
			l.Fatal(err)
		}
	}
	embedPluginConfs(plugins, l)
	updateGlockfileAndInstall(l)
	l.Info("Success!")
}
예제 #2
0
파일: abot.go 프로젝트: itsabot/abot
func installPlugins(l *log.Logger, errChan chan errMsg) {
	if err := core.LoadConf(); err != nil {
		errChan <- errMsg{msg: "", err: err}
		return
	}
	plugins := buildPluginFile(l)

	// Fetch all plugins
	if len(plugins.Dependencies) == 1 {
		l.Infof("Fetching 1 plugin...\n")
	} else {
		l.Infof("Fetching %d plugins...\n", len(plugins.Dependencies))
	}
	outC, err := exec.
		Command("/bin/sh", "-c", "go get ./...").
		CombinedOutput()
	if err == nil {
		syncDependencies(plugins, l, errChan)
		return
	}

	// Show errors only when it's not a private repo issue
	if !strings.Contains(string(outC), "fatal: could not read Username for") {
		errChan <- errMsg{msg: string(outC), err: err}
		return
	}

	// TODO enable versioning for private repos
	l.Infof("Fetching private repos...\n\n")
	l.Info("*** This will delete your local plugins to fetch remote copies.")
	_, err = fmt.Print("Continue? [n]: ")
	if err != nil {
		errChan <- errMsg{msg: "", err: err}
		return
	}
	reader := bufio.NewReader(os.Stdin)
	text, err := reader.ReadString('\n')
	if err != nil {
		errChan <- errMsg{msg: "", err: errors.New("failed to read from stdin")}
		return
	}
	if text[0] != 'y' && text[0] != 'Y' {
		errChan <- errMsg{msg: "Canceled", err: nil}
		return
	}
	wg := &sync.WaitGroup{}
	for name, _ := range plugins.Dependencies {
		go clonePrivateRepo(name, errChan, wg)
	}
	wg.Wait()
	syncDependencies(plugins, l, errChan)
}