fix(taskwarrior): merge identifies if there are changes in the comments

This commit is contained in:
2023-10-26 17:40:44 +02:00
parent 896066f8a7
commit ce23c870fd

View File

@@ -363,7 +363,6 @@ func (issue *Issue) MergeTask(task taskwarrior.Task) taskwarrior.Task {
task.Status = diff.Prompt(task.Status, issue.git_issue.State, task.Status)
}
}
// TODO: try to automatically derive the correct required changes
var annotations []string
for _, annotation := range task.Annotations {
annotations = append(annotations, annotation.Description)
@@ -372,18 +371,25 @@ func (issue *Issue) MergeTask(task taskwarrior.Task) taskwarrior.Task {
for _, comment := range issue.comments {
comments = append(comments, comment.Body)
}
// FIXME: provide options for theirs, mine and manual edit of the task annotations
// FIXME: prompted for no right reason
// FIXME: changes the task incorrectly
annotation_joined := diff.Prompt(strings.Join(annotations, "\n\n"), strings.Join(comments, "\n\n"), strings.Join(annotations, "\n\n"))
for i, description := range strings.Split(annotation_joined, "\n\n") {
if len(description) == 0 {
continue
require_merge := false
if len(annotations) == len(comments) {
for i := range annotations {
if annotations[i] != comments[i] {
require_merge = true
}
}
if i < len(task.Annotations) {
task.Annotations[i].Description = description
} else {
task.AppendComment(-1, description, time.Now().In(time.Local))
}
if require_merge {
annotation_joined := diff.Prompt(strings.Join(annotations, "\n\n"), strings.Join(comments, "\n\n"), strings.Join(annotations, "\n\n"))
for i, description := range strings.Split(annotation_joined, "\n\n") {
if len(description) == 0 {
continue
}
if i < len(task.Annotations) {
task.Annotations[i].Description = description
} else {
task.AppendComment(-1, description, time.Now().In(time.Local))
}
}
}
} else {