GothenburgBitFactory / timewarrior

Timewarrior - Commandline Time Tracking and Reporting
https://timewarrior.net
MIT License
1.25k stars 94 forks source link

internal parsing of tags starting with number broken #580

Closed arxel-sc closed 8 months ago

arxel-sc commented 8 months ago

Hello,

since version 1.7.0 I see the following behaviour while handling tags that start with a number and contain a hyphen (see the 16-031):

[0] % tw start 8:26 16-031 'ticket cleanup' :debug
CLI Parser
  _original_args
    timew start 8:26 16-031 ticket cleanup :debug
  _args
    word basename='timew' raw='timew' BINARY
    word canonical='start' raw='start' ORIGINAL CMD
    date raw='8:26' ORIGINAL FILTER
    word raw='16-031' ORIGINAL FILTER TAG
    word raw='ticket cleanup' QUOTED ORIGINAL FILTER TAG
    word canonical=':debug' raw=':debug' ORIGINAL HINT FILTER

>> 2024-01.data: 32 intervals
>> Loaded 0 tracked intervals
Note: '16-031' is a new tag.
>> Datafile::addInterval() failed.
>> Encode / decode check failed:
>>   interval 2024-01-08T08:26:00 # 16-031 "ticket cleanup"
>> is not equal to:
>>   interval 2024-01-08T08:26:00 # -031 16 "ticket cleanup"
Internal error. Failed encode / decode check.
>> Timer timew 0.014058 sec

Same thing happens when I single quote AND when I double quote them. I can see, that the args get parsed correctly but somewhere in between the tag gets split. If I start the tag with a letter it gets handled correctly:

[0] % tw start C-BETR-111111 'my other tag' :debug
CLI Parser
  _original_args
    timew start C-BETR-111111 my other tag :debug
  _args
    word basename='timew' raw='timew' BINARY
    word canonical='start' raw='start' ORIGINAL CMD
    word raw='C-BETR-111111' ORIGINAL FILTER TAG
    word raw='my other tag' QUOTED ORIGINAL FILTER TAG
    word canonical=':debug' raw=':debug' ORIGINAL HINT FILTER

>> 2024-01.data: 32 intervals
>> Loaded 0 tracked intervals
Note: 'C-BETR-111111' is a new tag.
Note: '"my other tag"' is a new tag.
>> 2024-01.data: Added inc 20240108T102843Z # C-BETR-111111 "my other tag"
Tracking C-BETR-111111 "my other tag"
  Started 2024-01-08T11:28:43
  Current                  43
  Total               0:00:00
>> Moving '/home/scal/.timewarrior/data/2024-01.data.75561-2.tmp' -> '/home/scal/.timewarrior/data/2024-01.data'
>> Moving '/home/scal/.timewarrior/data/undo.data.75561-3.tmp' -> '/home/scal/.timewarrior/data/undo.data'
>> Moving '/home/scal/.timewarrior/data/tags.data.75561-4.tmp' -> '/home/scal/.timewarrior/data/tags.data'
>> Timer timew 0.045118 sec

Since we have accounts that use the format above starting with a number it would be nice if this could work again (does not matter to me if it needs quotes or not).

Last known working version was 1.6.0

lauft commented 8 months ago

It seems a change introduced in #576 is causing this.