func validateRepoOrder()

in cmd/publishing-bot/config/rules.go [132:151]


func validateRepoOrder(rules *RepositoryRules) (errs []error) {
	glog.Infof("validating repository order")
	indices := map[string]int{}
	for i, r := range rules.Rules {
		indices[r.DestinationRepository] = i
	}

	for i, r := range rules.Rules {
		for _, br := range r.Branches {
			for _, d := range br.Dependencies {
				if j, ok := indices[d.Repository]; !ok {
					errs = append(errs, fmt.Errorf("unknown dependency %q in repository rules of %q", d.Repository, r.DestinationRepository))
				} else if j > i {
					errs = append(errs, fmt.Errorf("repository %q cannot depend on %q later in the rules file. Please define rules for %q above the rules for %q", r.DestinationRepository, d.Repository, d.Repository, r.DestinationRepository))
				}
			}
		}
	}
	return errs
}