Exemplo n.º 1
0
// commitFiles adds file information to commit
func commitFiles(commit *meta.Commit, repo *meta.Repo, files map[string]int) {
	// Preallocation is the way to go
	commit.File = make([]meta.File, 0, len(files))
	for key, value := range files {
		if value == status.UNTRACKED || value == status.REMOVED {
			continue
		}
		s, err := crypto.SHA512(key)
		if err != nil {
			panic(err)
		}
		commit.File = append(commit.File, meta.File{xml.Name{"", "FILE"}, s, key})
	}
}
Exemplo n.º 2
0
// markStatus marks file status
func markStatus(commit *meta.Commit, files map[string]int) {
	if commit == nil {
		return
	}
	for _, cached := range commit.File {
		// compute sha and compare to cached
		title := cached.Title
		workingSHA, err := crypto.SHA512(title)
		switch {
		case err != nil:
			files[title] = REMOVED
		case workingSHA != cached.SHA:
			files[title] = MODIFIED
		default:
			files[title] = UNMODIFIED
		}
	}
}