Пример #1
0
func main() {
	flag.Parse()
	if len(*org) == 0 {
		glog.Fatalf("--organization is required.")
	}
	if len(*project) == 0 {
		glog.Fatalf("--project is required.")
	}
	tokenData := *token
	if len(tokenData) == 0 && len(*tokenFile) != 0 {
		data, err := ioutil.ReadFile(*tokenFile)
		if err != nil {
			glog.Fatalf("error reading token file: %v", err)
		}
		tokenData = string(data)
	}
	client := github.MakeClient(tokenData)

	if len(*issueMungers) > 0 {
		glog.Infof("Running issue mungers")
		if err := issues.MungeIssues(client, *issueMungers, *org, *project, *minIssueNumber, *dryrun); err != nil {
			glog.Errorf("Error munging issues: %v", err)
		}
	}
	if len(*prMungers) > 0 {
		glog.Infof("Running PR mungers")
		if err := pulls.MungePullRequests(client, *prMungers, *org, *project, *minPRNumber, *dryrun); err != nil {
			glog.Errorf("Error munging PRs: %v", err)
		}
	}
}
Пример #2
0
func doMungers(config *config.MungeConfig) error {
	if len(config.IssueMungers) == 0 && len(config.PRMungersList) == 0 {
		glog.Fatalf("must include at least one --issue-mungers or --pr-mungers")
	}
	for {
		nextRunStartTime := time.Now().Add(config.Period)
		if len(config.IssueMungers) > 0 {
			glog.Infof("Running issue mungers")
			if err := issues.MungeIssues(config); err != nil {
				glog.Errorf("Error munging issues: %v", err)
			}
		}
		if len(config.PRMungersList) > 0 {
			glog.Infof("Running PR mungers")
			if err := pulls.MungePullRequests(config); err != nil {
				glog.Errorf("Error munging PRs: %v", err)
			}
		}
		config.ResetAPICount()
		if config.Once {
			break
		}
		if nextRunStartTime.After(time.Now()) {
			sleepDuration := nextRunStartTime.Sub(time.Now())
			glog.Infof("Sleeping for %v\n", sleepDuration)
			time.Sleep(sleepDuration)
		} else {
			glog.Infof("Not sleeping as we took more than %v to complete one loop\n", config.Period)
		}
	}
	return nil
}
Пример #3
0
func main() {
	flag.Parse()
	if len(o.Org) == 0 {
		glog.Fatalf("--organization is required.")
	}
	if len(o.Project) == 0 {
		glog.Fatalf("--project is required.")
	}
	tokenData := *token
	if len(tokenData) == 0 && len(*tokenFile) != 0 {
		data, err := ioutil.ReadFile(*tokenFile)
		if err != nil {
			glog.Fatalf("error reading token file: %v", err)
		}
		tokenData = string(data)
	}
	client := github.MakeClient(tokenData)

	if len(*issueMungers) == 0 && len(*prMungers) == 0 {
		glog.Fatalf("must include at least one --issue-mungers or --pr-mungers")
	}
	for {
		if len(*issueMungers) > 0 {
			glog.Infof("Running issue mungers")
			if err := issues.MungeIssues(client, *issueMungers, o); err != nil {
				glog.Errorf("Error munging issues: %v", err)
			}
		}
		if len(*prMungers) > 0 {
			glog.Infof("Running PR mungers")
			if err := pulls.MungePullRequests(client, *prMungers, o); err != nil {
				glog.Errorf("Error munging PRs: %v", err)
			}
		}
		if *oneOff {
			break
		}
		time.Sleep(*period)
	}
}
Пример #4
0
func main() {
	flag.Parse()
	if len(*org) == 0 {
		glog.Fatalf("--organization is required.")
	}
	if len(*project) == 0 {
		glog.Fatalf("--project is required.")
	}
	client := github.MakeClient(*token)

	if len(*issueMungers) > 0 {
		glog.Infof("Running issue mungers")
		if err := issues.MungeIssues(client, *issueMungers, *org, *project, *minIssueNumber, *dryrun); err != nil {
			glog.Errorf("Error munging issues: %v", err)
		}
	}
	if len(*prMungers) > 0 {
		glog.Infof("Running PR mungers")
		if err := pulls.MungePullRequests(client, *prMungers, *org, *project, *minPRNumber, *dryrun); err != nil {
			glog.Errorf("Error munging PRs: %v", err)
		}
	}
}