Exemplo n.º 1
0
func main() {

	only_new, conf_file := parse_args()

	cfg, err := ReadConfig(conf_file)
	if err != nil {
		fmt.Printf("Error reading config - %s\n", err)
		return
	}

	gerrit = g.New(cfg.Gerrit.User, cfg.Gerrit.Password, cfg.Gerrit.Host, cfg.Gerrit.CI)

	if cfg.Gerrit.Connections > 0 {
		Concurrent_GETs = cfg.Gerrit.Connections
	}

	theme = NewColorTheme(&cfg.Color)

	// format:  alias:fullname
	proj_alias = make(map[string]string)
	for _, alias := range cfg.Project.Alias {
		parts := strings.SplitN(alias, ":", 2)
		proj_alias[parts[1]] = parts[0]
	}

	// format: alias:CIname
	proj_ci = make(map[string]string)
	for _, line := range cfg.Project.CI {
		parts := strings.SplitN(line, ":", 2)
		proj_ci[parts[0]] = parts[1]
	}

	// callback func
	ci_name_cb := func(p string) string {
		proj, found := proj_alias[p]
		if !found {
			proj = p
		}
		ci, found := proj_ci[proj]
		if !found {
			ci = cfg.Gerrit.CI
		}
		return ci
	}
	gerrit.SetCICallback(ci_name_cb)

	dashboard("?q=owner:self+status:open", only_new)
	dashboard("?q=is:reviewer+status:open+-owner:self", only_new)
}
Exemplo n.º 2
0
func main() {
	verbose, conf_file := parse_args()

	cfg, err := ReadConfig(conf_file)
	if err != nil {
		log.Fatalf("Error reading config %s - %s\n", conf_file, err)
	}

	profile := cfg.Robot.Profile

	ticker, err := time.ParseDuration(cfg.Robot.Interval)
	if err != nil {
		log.Fatalf("Failed to parse [Robot]Interval: %s", err)
	}

	gerrit = g.New(cfg.Gerrit.User, cfg.Gerrit.Password, cfg.Gerrit.Host, cfg.Gerrit.CI)
	last_updated = make(map[string]string)

	if profile != "" {
		// start profile server
		go func() {
			log.Println(http.ListenAndServe(profile, nil))
		}()
		log.Printf("Started profiling server on %s", profile)
	}

	project_list := cfg.Robot.Project
	//query := "?q=is:reviewer+status:open+-owner:self+p:{PROJECT}"
	query := "?q=is:reviewer+status:open+-owner:self"
	dashboard(query, project_list, verbose)

	ticker_chan := time.NewTicker(ticker).C

	for {
		select {
		case _ = <-ticker_chan:
			log.Println("Tick")
			dashboard(query, project_list, verbose)
		}
	}
}