コード例 #1
0
ファイル: commit.go プロジェクト: skirkpatrick/svc
// 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})
	}
}
コード例 #2
0
ファイル: status.go プロジェクト: skirkpatrick/svc
// 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
		}
	}
}