mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-07-03 22:28:29 +00:00
compare: implement mtree.DirectoryHierarchy comparisons
This is part of a patchset that refactors all of the checking logic into comparison operations. Essentially, provide a Compare(...) function that allows for two different manifests to be compared. Extra and missing entries are supported in addition to the standard modified entry, and by implementing as a manifest comparison there is no double-scanning of the manifest source. The main annoyance is that we have to also include tar_time handling, which has not been abstracted inside keywords.go. This is a bit ugly right now, but works fine for the moment. Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
parent
36372dd3c8
commit
26ff922da6
3 changed files with 776 additions and 0 deletions
|
@ -78,6 +78,15 @@ func (kv KeyVal) ChangeValue(newval string) string {
|
|||
return fmt.Sprintf("%s=%s", kv.Keyword(), newval)
|
||||
}
|
||||
|
||||
// KeyValEqual returns whether two KeyVals are equivalent. This takes
|
||||
// care of certain odd cases such as tar_mtime, and should be used over
|
||||
// using == comparisons directly unless you really know what you're
|
||||
// doing.
|
||||
func KeyValEqual(a, b KeyVal) bool {
|
||||
// TODO: Implement handling of tar_mtime.
|
||||
return a.Keyword() == b.Keyword() && a.Value() == b.Value()
|
||||
}
|
||||
|
||||
// keywordSelector takes an array of "keyword=value" and filters out that only the set of words
|
||||
func keywordSelector(keyval, words []string) []string {
|
||||
retList := []string{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue