GothenburgBitFactory / GothenburgBitFactory/taskwarrior

DOM references in `task add` are inconsistent

Open
#2,705 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
6.1k
Forks
423
Avg merge
1d 19h
Merged PRs (30d)
11

Description

OK, I'm legit confused about the intent here.

dom2.t calls `add three due:20110901 wait:due +tag1 +tag2` and expects `wait:due` to refer to the `due` value set earlier on the command line. OK, cool, I can make that work by setting the contextTask to be the newly created task in CmdAdd.cpp, so that DOM references search the values already set on the task as the command line is processed.

..but in that case, "project.t: 1900: Project name can contain dashes" checks `task add foo project:due-b` expects project to be `due-b`, but since there's a context task it substitutes the empty string for the `due` DOM reference and gets `-b` instead.

In 2.6.1:
```
cleave ~ $ task add foo proj:due-b
Created task 166.
The project 'due-b' has changed. Project 'due-b' is 0% complete (1 task remaining).
cleave ~ $ task add foo wait:2d proj:due-b
Created task 167.
The project '-b' has changed. Project '-b' is 0% complete (1 task remaining).
```
so it seems that DOM references are only left un-parsed in `task add` if they are in the first non-description attribute (so basically, they're always empty).

In 2.5.1:
```
dorp ~ $ task add foo proj:due-b
Cannot subtract strings
```

and in 2.6.1, on a task with a `due` property:
```
cleave ~ $ task 117 modify proj:due-b
Cannot subtract strings
```
but
```
cleave ~ $ task 117 modify proj:due
Modifying task 117 '...'.
Modified 1 task.
The project '2021-12-16T23:00:00' has changed. Project '2021-12-16T23:00:00' is 0% complete (1 task remaining).
```

So, this is new behavior, and wildly inconsistent. I think the test checking `proj:due-b` is incidentally asserting something about DOM references that is not intentional and only *happens* to work, in some versions, in some situations. So I'm going to change the test to `proj:doo-bee`, which still has the dash named in the test description.

_Originally posted by @djmitche in https://github.com/GothenburgBitFactory/taskwarrior/issues/2683#issuecomment-997121680_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.