func (dir *CharmDir) buildIgnoreRules() (ignoreRuleset, error) {
	// Start with a set of sane defaults to ensure backwards-compatibility
	// for charms that do not use a .jujuignore file.
	rules, err := newIgnoreRuleset(strings.NewReader(defaultJujuIgnore))
	if err != nil {
		return nil, err
	}

	pathToJujuignore := dir.join(".jujuignore")
	if _, err := os.Stat(pathToJujuignore); err == nil {
		file, err := os.Open(dir.join(".jujuignore"))
		if err != nil {
			return nil, errors.Annotatef(err, `reading ".jujuignore" file`)
		}
		defer func() { _ = file.Close() }()

		jujuignoreRules, err := newIgnoreRuleset(file)
		if err != nil {
			return nil, errors.Annotate(err, `parsing ".jujuignore" file`)
		}

		rules = append(rules, jujuignoreRules...)
	}

	return rules, nil
}
// buildIgnoreRules parses the contents of the charm's .jujuignore file and
// compiles a set of rules that are used to decide which files should be
// archived.
buildIgnoreRules parses the contents of the charm's .jujuignore file and
compiles a set of rules that are used to decide which files should be
archived.
// buildIgnoreRules parses the contents of the charm ' s . jujuignore file and // compiles a set of rules that are used to decide which files should be // archived .
func (dir *CharmDir) buildIgnoreRules() (ignoreRuleset, error) {
	rules, err := newIgnoreRuleset(strings.NewReader(defaultJujuIgnore))
	if err != nil {
		return nil, err
	}
	pathToJujuignore := dir.join(".jujuignore")
	if _, err := os.Stat(pathToJujuignore); err == nil {
		file, err := os.Open(dir.join(".jujuignore"))
		if err != nil {
			return nil, errors.Annotatef(err, `reading ".jujuignore" file`)
		}
		defer func() { _ = file.Close() }()
		jujuignoreRules, err := newIgnoreRuleset(file)
		if err != nil {
			return nil, errors.Annotate(err, `parsing ".jujuignore" file`)
		}
		rules = append(rules, jujuignoreRules...)
	}
	return rules, nil
}
func ( dir * CharmDir ) buildIgnoreRules ( ) ( ignoreRuleset , error ) { rules , err := newIgnoreRuleset ( strings . NewReader ( defaultJujuIgnore ) ) if err != nil { return nil , err } pathToJujuignore := dir . join ( " " ) if _ , err := os . Stat ( pathToJujuignore ) ; err == nil { file , err := os . Open ( dir . join ( " " ) ) if err != nil { return nil , errors . Annotatef ( err , `reading ".jujuignore" file` ) } defer func ( ) { _ = file . Close ( ) } ( ) jujuignoreRules , err := newIgnoreRuleset ( file ) if err != nil { return nil , errors . Annotate ( err , `parsing ".jujuignore" file` ) } rules = append ( rules , jujuignoreRules ... ) } return rules , nil }
buildIgnoreRules parses the contents of the charm's .jujuignore file and
compiles a set of rules that are used to decide which files should be
archived.
buildIgnoreRules parses the contents of the charm ' s . jujuignore file and compiles a set of rules that are used to decide which files should be archived .
// Start with a set of sane defaults to ensure backwards-compatibility // for charms that do not use a .jujuignore file.