add(taskwarrior): merge of server side changes for milestones
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitea.yves-biener.de/yves-biener/gitwarrior/internal/diff"
|
||||
"gitea.yves-biener.de/yves-biener/gitwarrior/internal/gitea"
|
||||
"gitea.yves-biener.de/yves-biener/gitwarrior/internal/taskwarrior"
|
||||
)
|
||||
@@ -99,10 +100,7 @@ func (project *Project) merge() error {
|
||||
tasks = append(tasks, task)
|
||||
} else {
|
||||
// NOTE: there is excactly one git_task
|
||||
task, err = issue.MergeTask(git_tasks[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
task = issue.MergeTask(git_tasks[0])
|
||||
fmt.Printf("\tUpdated task: '%s'\n", task.Description)
|
||||
tasks = append(tasks, task)
|
||||
}
|
||||
@@ -196,18 +194,18 @@ func (issue *Issue) IntoTask(repository gitea.Repository) (task taskwarrior.Task
|
||||
}
|
||||
|
||||
// TODO: implement merging of git issue or milestone into a taskwarrior task
|
||||
func (issue *Issue) MergeTask(task taskwarrior.Task) (taskwarrior.Task, error) {
|
||||
func (issue *Issue) MergeTask(task taskwarrior.Task) taskwarrior.Task {
|
||||
last_update := taskwarrior.TaskTimeToGoTime(task.Last_gitw_update)
|
||||
if issue.git_issue.Updated_at.After(last_update) {
|
||||
// there are changes we need to merge
|
||||
if taskwarrior.TaskTimeToGoTime(task.Modified).After(last_update) {
|
||||
// NOTE: this means that there are local modifications which are not yet pushed
|
||||
if task.Description != issue.git_issue.Title {
|
||||
task.Description = prompt(task.Description, issue.git_issue.Title, task.Description)
|
||||
task.Description = diff.Prompt(task.Description, issue.git_issue.Title, task.Description)
|
||||
}
|
||||
if task.Status == "completed" || issue.git_issue.State == "closed" {
|
||||
if !(task.Status == "completed" && issue.git_issue.State == "closed" || task.Status != "completed" && issue.git_issue.State != "closed") {
|
||||
task.Status = prompt(task.Status, issue.git_issue.State, task.Status)
|
||||
task.Status = diff.Prompt(task.Status, issue.git_issue.State, task.Status)
|
||||
}
|
||||
}
|
||||
if len(task.Annotations) != len(issue.comments) {
|
||||
@@ -233,7 +231,7 @@ func (issue *Issue) MergeTask(task taskwarrior.Task) (taskwarrior.Task, error) {
|
||||
annotation.Description = comment.Body
|
||||
annotation.Entry = taskwarrior.GoTimeToTaskTime(comment.Updated_at)
|
||||
} else {
|
||||
annotation.Description = prompt(annotation.Description, comment.Body, annotation.Description)
|
||||
annotation.Description = diff.Prompt(annotation.Description, comment.Body, annotation.Description)
|
||||
}
|
||||
task.Annotations[i] = annotation
|
||||
}
|
||||
@@ -260,12 +258,5 @@ func (issue *Issue) MergeTask(task taskwarrior.Task) (taskwarrior.Task, error) {
|
||||
}
|
||||
task.Last_gitw_update = taskwarrior.GoTimeToTaskTime(time.Now().In(time.Local))
|
||||
}
|
||||
// TODO: issue values into task:
|
||||
// - is the issue more recent than the task?
|
||||
// - apply changes into task
|
||||
// - in case of merge conflicts ask user for corresponding action:
|
||||
// 1. use theirs
|
||||
// 2. use mine
|
||||
// 3. use provided value
|
||||
return task, nil
|
||||
return task
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user