Skip to content

Commit

Permalink
Edit project bugfix (#231)
Browse files Browse the repository at this point in the history
* bump version

* Fix bug with editing a project

Co-authored-by: Grant Ammons <[email protected]>
  • Loading branch information
gammons and Grant Ammons authored Oct 30, 2020
1 parent 65c8a7b commit 00a732d
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Envs = [
{ goos: "windows", arch: "amd64" }
].freeze

Version = "1.6.0".freeze
Version = "1.6.1".freeze

task :build do
`rm -rf dist/#{Version}`
Expand Down
2 changes: 1 addition & 1 deletion ultralist/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

// Current version of ultralist.
const (
VERSION string = "1.6.0"
VERSION string = "1.6.1"
DATE_FORMAT string = "2006-01-02"
)

Expand Down
8 changes: 8 additions & 0 deletions ultralist/edit_todo.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,13 @@ func EditTodo(todo *Todo, filter *Filter) error {
todo.Subject = filter.Subject
}

if len(filter.Projects) > 0 {
todo.Projects = filter.Projects
}

if len(filter.Contexts) > 0 {
todo.Contexts = filter.Contexts
}

return nil
}
37 changes: 37 additions & 0 deletions ultralist/edit_todo_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package ultralist

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestEditTodoProjects(t *testing.T) {
assert := assert.New(t)
parser := &InputParser{}

filter, _ := parser.Parse("+p1")
todo, _ := CreateTodo(filter)

editFilter, _ := parser.Parse("+p2")

EditTodo(todo, editFilter)

assert.Equal("+p2", todo.Subject)
assert.Equal([]string{"p2"}, todo.Projects)
}

func TestEditTodoProjectsOtherSyntax(t *testing.T) {
assert := assert.New(t)
parser := &InputParser{}

filter, _ := parser.Parse("+p1")
todo, _ := CreateTodo(filter)

editFilter, _ := parser.Parse("project:p2")

EditTodo(todo, editFilter)

assert.Equal("+p1", todo.Subject)
assert.Equal([]string{"p2"}, todo.Projects)
}
2 changes: 2 additions & 0 deletions ultralist/input_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,14 @@ func (p *InputParser) Parse(input string) (*Filter, error) {
if r.MatchString(word) {
filter.HasProjectFilter = true
filter.Projects, filter.ExcludeProjects = p.parseString(r.FindString(word)[8:])
match = true
}

r, _ = regexp.Compile(`context:.*$`)
if r.MatchString(word) {
filter.HasContextFilter = true
filter.Contexts, filter.ExcludeContexts = p.parseString(r.FindString(word)[8:])
match = true
}

if !match {
Expand Down

0 comments on commit 00a732d

Please sign in to comment.