diff --git a/internal/gitw/project.go b/internal/gitw/project.go index 49de6b3..e6d67ca 100644 --- a/internal/gitw/project.go +++ b/internal/gitw/project.go @@ -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 {