add root.equals and todo.equals
This commit is contained in:
@@ -43,3 +43,37 @@ func (todo *Todo) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
alt := (*Alt)(todo)
|
||||
return unmarshal(alt)
|
||||
}
|
||||
|
||||
func (todo Todo) Equals(other Todo) bool {
|
||||
if !equalTodoSlices(todo.Subtasks, other.Subtasks) {
|
||||
return false
|
||||
}
|
||||
if todo.TS != other.TS {
|
||||
return false
|
||||
}
|
||||
if todo.Tags != other.Tags {
|
||||
return false
|
||||
}
|
||||
if todo.Schedule != other.Schedule {
|
||||
return false
|
||||
}
|
||||
if todo.Details != other.Details {
|
||||
return false
|
||||
}
|
||||
if todo.Todo != other.Todo {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func equalTodoSlices(a, b []Todo) bool {
|
||||
if len(a) != len(b) {
|
||||
return false
|
||||
}
|
||||
for i := range a {
|
||||
if !a[i].Equals(b[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user