mirror of
https://github.com/restic/restic.git
synced 2025-12-03 23:51:51 +00:00
Allow --tag and --keep-tag to match untagged snapshots
This commit is contained in:
committed by
Leo R. Lundgren
parent
5571c3f7fd
commit
326fefcd80
@@ -195,6 +195,9 @@ func (sn *Snapshot) hasTag(tag string) bool {
|
||||
// HasTags returns true if the snapshot has all the tags in l.
|
||||
func (sn *Snapshot) HasTags(l []string) bool {
|
||||
for _, tag := range l {
|
||||
if tag == "" && len(sn.Tags) == 0 {
|
||||
return true
|
||||
}
|
||||
if !sn.hasTag(tag) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -14,3 +14,13 @@ func TestNewSnapshot(t *testing.T) {
|
||||
_, err := restic.NewSnapshot(paths, nil, "foo", time.Now())
|
||||
rtest.OK(t, err)
|
||||
}
|
||||
|
||||
func TestTagList(t *testing.T) {
|
||||
paths := []string{"/home/foobar"}
|
||||
tags := []string{""}
|
||||
|
||||
sn, _ := restic.NewSnapshot(paths, nil, "foo", time.Now())
|
||||
|
||||
r := sn.HasTags(tags)
|
||||
rtest.Assert(t, r, "Failed to match untagged snapshot")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user