Example #1
0
func (fs *FileSet) visit(path string, info os.FileInfo, err error) error {
	if err != nil {
		log.Printf("visitor failed on %q: %s", path, err)
		return nil
	}
	included := false
	for _, inc := range fs.Include {
		if glob.Glob(inc, path) {
			included = true
			break
		}
	}
	excluded := false
	for _, exc := range fs.Exclude {
		if strings.Index(path, exc) != -1 {
			excluded = true
			break
		}
	}
	if included && !excluded && !info.IsDir() {
		fs.Matches = append(fs.Matches, path)
		//log.Printf("path allowed: %q", path)
		return nil
	}
	if !included && !excluded {
		//log.Printf("path ignored: %q", path)
		return nil
	}
	if excluded && info.IsDir() {
		//log.Printf("path ignoring directory %q", path)
		return filepath.SkipDir
	}
	//log.Printf("Included then excluded: %q", path)
	return nil
}
// WorkflowIDByPattern ...
func (config *BitriseDataModel) WorkflowIDByPattern(pattern, pullRequestID string) (string, bool, error) {
	for _, item := range config.TriggerMap {
		if glob.Glob(item.Pattern, pattern) {
			if !item.IsPullRequestAllowed && pullRequestID != "" {
				return "", true, fmt.Errorf("Trigger pattern (%s) match found, but pull request is not enabled", pattern)
			}
			return item.WorkflowID, true, nil
		}
	}
	return "", false, nil
}
Example #3
0
func emptyOrGlob(userVal, fieldVal string) bool {
	if userVal == "empty" && fieldVal == "" {
		return true
	}
	return glob.Glob(userVal, fieldVal)
}