From 96cc4ce27c8f3a437042bbef8b69e6c5123f6638 Mon Sep 17 00:00:00 2001 From: "jamesclonk@jamesclonk.ch" Date: Sat, 4 Jan 2014 16:32:40 +0100 Subject: [PATCH] make sure Projects and Contexts are sorted --- task.go | 2 ++ todotxt.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/task.go b/task.go index ba8c083..0a4d7e8 100644 --- a/task.go +++ b/task.go @@ -53,12 +53,14 @@ func (task Task) String() string { text += task.Todo if len(task.Contexts) > 0 { + sort.Strings(task.Contexts) for _, context := range task.Contexts { text += fmt.Sprintf(" @%s", context) } } if len(task.Projects) > 0 { + sort.Strings(task.Projects) for _, project := range task.Projects { text += fmt.Sprintf(" +%s", project) } diff --git a/todotxt.go b/todotxt.go index dee8c10..67ff339 100644 --- a/todotxt.go +++ b/todotxt.go @@ -188,7 +188,7 @@ func (tasklist *TaskList) LoadFromFilename(filename string) error { // WriteToFilename writes a TaskList to the specified file (most likely called "todo.txt"). func (tasklist *TaskList) WriteToFilename(filename string) error { - return ioutil.WriteFile(filename, []byte(tasklist.String()), 0644) + return ioutil.WriteFile(filename, []byte(tasklist.String()), 0640) } // LoadFromFile loads and returns a TaskList from *os.File.