Ejemplo n.º 1
0
// CalculateSousHash returns a hash of the current version of Sous and its main
// configuration file.
func CalculateSousHash() string {
	inputs := []string{cmd.Stdout("sous", "version")}
	if c, ok := file.ReadString("~/.sous/config"); ok {
		inputs = append(inputs, c)
	}
	return HashSum(inputs...)
}
Ejemplo n.º 2
0
// CalculateTreeHash returns a hash of the current state of the working tree,
// leaning heavily on git for optimisation.
func CalculateTreeHash() string {
	inputs := []string{}
	indexDiffs := cmd.Stdout("git", "diff-index", "HEAD")
	if len(indexDiffs) != 0 {
		inputs = append(inputs, indexDiffs)
	}
	newFiles := git.UntrackedUnignoredFiles()
	if len(newFiles) != 0 {
		for _, f := range newFiles {
			inputs = append(inputs, f)
			if content, ok := file.ReadString(f); ok {
				inputs = append(inputs, content)
			}
		}
	}
	return HashSum(inputs...)
}