Commit graph

2875 commits

Author SHA1 Message Date
Shaun Ruffell
45eec2f7a0 Add test for command continue with future time
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-21 23:03:53 +02:00
Thomas Lauf
8b9389b5ad Add hash for version 1.3.0
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-21 21:41:20 +02:00
Shaun Ruffell
9d43727c09 Use only the current interval duration when summarizing
There are several instances where the "total" reported in the interval
summary is confusing because the summarize function would walk backward
and add all intervals with the same set of tags.

Closes #248 and #308

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-21 21:41:20 +02:00
Thomas Lauf
7405d2be96 Drop empty intervals during overlap resolution
- Closes #372

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-21 18:08:13 +02:00
Thomas Lauf
8daf11328d Add starting times to start command
- It seems that recent changes made the `stop` command faster such that these tests aborted with "The end of a date range must be after the start."

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
Thomas Lauf
55ea1aafce Fix typo
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
Thomas Lauf
abf4784aba Command start now hints for command continue if called with ids
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
Thomas Lauf
e69bd4b03b Coding style: Add spaces
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
Thomas Lauf
3feba61459 Rework stop command
- Compute the set difference between the latest interval's tag set and the given tag set
- If no tags given, the difference is set to `{}`
- In case of an empty difference, close the current open interval, apply exclusions and update the database
- In case of a non-empty difference, just add a new open interval and let the overlap resolution do the job...

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
Thomas Lauf
96aaa71eb4 Move validation for tag set up
- The given set of tags must be a subset of the latest interval's tag set (this includes the empty case)
- If not a subset, throw an error and show the first non-matching tag
- This also prevents the stop command from doing any work on the database
- Closes #280

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
Thomas Lauf
5b1c77b8aa Move validation of filter range up
- Use default range starting at `now`
- Add check for no datetime given (rare case of e.g. `timew stop :all`)

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
Thomas Lauf
990e0772d0 Add tests for stop command
- Stop with no datetime (rare case of e.g. `timew stop :all`)
    - `stop` with tag after `start` without tags
2020-08-19 15:41:34 +02:00
Thomas Lauf
7858bf4be8 Inline cli.getIds ()
- It is only used to hint for the modify command if any ids are given

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 14:10:57 +02:00
Thomas Lauf
11877d3fff Restrict application of exclusions to range before now for open intervals
- Closes #370

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-18 18:58:05 +02:00
Shaun Ruffell
26fdebf754 CmdReport: Throw error if report fails to produce output
Ideally this would be fixed in libshared.

See GothenburgBitFactory/libshared#27

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-17 13:05:33 +02:00
Shaun Ruffell
670fc289e9 CmdDiagnostics: Show per-file error messages.
I had a broken symbolic link in my extensions directory. When I ran
`timew diag` it would simply print on the screen:

```
stat error 2: No such file or directory
```

After this change, there is more context information about the source of
the error:

```
  timew 1.3.0
         Platform: Linux

  Compiler:
          Version: 7.5.0
             Caps: +stdc +stdc_hosted +LP64 +c8 +i32 +l64 +vp64 +time_t64
       Compliance: C++11

  Build Features
            Built: Aug 14 2020 05:57:06
           Commit: 6fe15d26
            CMake: 3.10.2
       Build type: Debug

  Configuration
    TIMEWARRIORDB: -
              Cfg: /home/sruffell/.timewarrior/timewarrior.cfg (-rw- 0 bytes)
         Database: /home/sruffell/.timewarrior (drwx 4096 bytes)
          $EDITOR: vim
      Color theme: Built-in default
                   00 01 02 03 04 05 06 07 08 09 10 11 12

  Extensions
         Location: /home/sruffell/.timewarrior/extensions (drwx 4096 bytes)
                   /home/sruffell/.timewarrior/extensions/tsheet (stat error 2: No such file or directory)
```

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-17 13:05:33 +02:00
Thomas Lauf
0137703512 Update libshared
- Version containing #26 which fixes a compilation error on FreeBSD
- Related to #258

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-16 16:04:49 +02:00
Thomas Lauf
02491f8153 Restore behaviour for adding a new interval with same tag set
- Closes #351

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-14 22:33:16 +02:00
Thomas Lauf
ea33b29986 Coding style: add spaces
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-13 10:12:16 +02:00
Thomas Lauf
e57fadc7a7 Fix comments
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-13 10:12:16 +02:00
Thomas Lauf
0db5598aa6 Add brackets to if-/for-statement
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-13 10:12:16 +02:00
Thomas Lauf
f00c4b9464 Use Range::is_started ()/Range::is_ended () instead of accessing range.start/range.end
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-13 10:12:16 +02:00
Thomas Lauf
bffce7ef28 Use empty() instead of size () == 0
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-13 10:12:16 +02:00
Thomas Lauf
a4a16ec2c5 Use const bool uniformly for variable 'verbose'
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-13 10:12:16 +02:00
Thomas Lauf
6fe15d2643 Enter new URL for distribution package list
- Changed from `/docs/download.html` to `/docs/install.html`

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-13 10:12:16 +02:00
Shaun Ruffell
e99eee55d8 CmdHelp: Include wait.h for exit() support.
Fixes the following errors when compiling on FreeBSD 12.1:

  [ 75%] Building CXX object src/commands/CMakeFiles/commands.dir/CmdHelp.cpp.o
  /home/user/timew-1.3.0/src/commands/CmdHelp.cpp:123:13: error: use of undeclared identifier 'WIFEXITED'
  return (WIFEXITED (ret)) ? WEXITSTATUS (ret) : -1;
  ^
  /home/user/timew-1.3.0/src/commands/CmdHelp.cpp:123:32: error: use of undeclared identifier 'WEXITSTATUS'
  return (WIFEXITED (ret)) ? WEXITSTATUS (ret) : -1;
  ^
  2 errors generated.
  *** Error code 1

Thanks @kbcb
Related to issue #258

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-13 09:51:31 +02:00
Thomas Lauf
566d14bc08 Use latest release version in README.md
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-12 16:43:25 +02:00
Shaun Ruffell
22dc0efa70 test: Add test to ensure Datafile throws when deleteInterval fails
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-11 10:39:34 +02:00
Shaun Ruffell
7481dab8d0 Datafile: Throw exception if Datafile::deleteInterval fails
This is particularly bad when called from the Database::modifyInterval
call, since the delete may fail, but then the addInterval will proceed.

Closes #319

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-11 10:39:34 +02:00
Shaun Ruffell
48baa27057 test: Move TempDir to standalone file
I would like to use TempDir for the Datafile test in order to cleanup
any datafiles created as part of the test.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-11 10:39:34 +02:00
Shaun Ruffell
eae8746df2 test: Add the timew binary as dependency of test target
If the timew binary changes, we should rebuild it before running
through the python tests.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-11 10:39:34 +02:00
Shaun Ruffell
c75d9fefad test: Remove unused variables from DatetimeParser.t
Quiets the following warnings when building the test:

  test/DatetimeParser.t.cpp: In function ‘int main(int, char**)’:
  test/DatetimeParser.t.cpp:163:7: warning: unused variable ‘hm’ [-Wunused-variable]
     int hm  = (12 * 3600) + (34 * 60);      // The time 12:34:00 in seconds.
         ^~
  test/DatetimeParser.t.cpp:164:7: warning: unused variable ‘z’ [-Wunused-variable]
     int z   = 3600;                         // TZ offset.
         ^
  test/DatetimeParser.t.cpp:317:7: warning: unused variable ‘t8a’ [-Wunused-variable]
     int t8a   = (8 * 3600);
         ^~~
  test/DatetimeParser.t.cpp:318:7: warning: unused variable ‘t830a’ [-Wunused-variable]
     int t830a = (8 * 3600) + (30 * 60);
         ^~~~~
  test/DatetimeParser.t.cpp:319:7: warning: unused variable ‘t8p’ [-Wunused-variable]
     int t8p   = (20 * 3600);
         ^~~
  test/DatetimeParser.t.cpp:320:7: warning: unused variable ‘t830p’ [-Wunused-variable]
     int t830p = (20 * 3600) + (30 * 60);
         ^~~~~
  test/DatetimeParser.t.cpp:321:7: warning: unused variable ‘t12p’ [-Wunused-variable]
     int t12p  = (12 * 3600);
         ^~~~
  test/DatetimeParser.t.cpp:322:7: warning: unused variable ‘t1p’ [-Wunused-variable]
     int t1p   = (13 * 3600);
         ^~~
  test/DatetimeParser.t.cpp:325:7: warning: variable ‘adjust’ set but not used [-Wunused-but-set-variable]
     int adjust = (time_now.hour () > 10 || (time_now.hour () == 10 && time_now.minute () > 30)) ? 86400 : 0;
         ^~~~~~

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-11 10:39:34 +02:00
Shaun Ruffell
a87117db09 Remove undo file if empty
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-10 22:24:52 +02:00
Shaun Ruffell
b0efdbc9ee Datafile: Remove empty files
If calling undo on an operation the removes many entries from the
datafiles, there would be many 0 length size files remaining in the data
directory. Now they will be removed if they are empty so they will not
longer need to be checked when parsing the database.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-10 22:24:52 +02:00
Shaun Ruffell
b2a8fe6f55 test: Add tests for -1, 0, 1, and 2 'journal.size' settings
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-10 22:24:52 +02:00
Shaun Ruffell
a1e2def1a8 Introduce 'journal.size' config setting.
Allows the user to specify a maximum number of entries to store in the
undo file. By default the behavior is unchanged, and the file will grow
unbounded without user intervention.

journal.size = 0 will disable storing any entries, journal.size < 0
indicates that the size of the journal should be unlimited (the
default), otherwise it indicates the number of entries to store.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-10 22:24:52 +02:00
Shaun Ruffell
0a4644bfc7 AtomicFile: Add size() and remove() methods
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-10 22:24:52 +02:00
Shaun Ruffell
cea2e5d13f Only show tag in chart if utf8 character width is within the width
- Closes #309

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-17 21:44:22 +02:00
Thomas Lauf
06a4235b10 Move start of transaction down to actual database methods
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-17 17:53:59 +02:00
Thomas Lauf
b5aec4db8b Remove flattening of database in CmdContinue
- Should now be done during overlap resolution in `validate.cpp`

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-17 17:53:04 +02:00
Thomas Lauf
6bf708dbeb Use dynamic test data for interval enclosing a month border in delete.t
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-17 13:59:05 +02:00
Thomas Lauf
90b5b1085e Adapt delete.t and move.t as today is now interpreted as a range
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-15 17:22:32 +02:00
Thomas Lauf
c35a08719f Move handling of starting a interval with identical tag set as the current tracking to standard overlap resolution
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-14 13:58:54 +02:00
Thomas Lauf
6618231002 CmdStart shall not accept ranges as input
- This also handles the case when it is called with the `:all` hint
- When called with a range, the `track` command is recommended
- There is no forwarding to `track`

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-14 13:57:15 +02:00
Thomas Lauf
91c246c42f CmdStart should not redirect to CmdTrack but issue an error message when called with range
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-13 16:40:37 +02:00
Shaun Ruffell
cc82f468e1 CmdStart: Honor the :adjust flag when overwriting a currently open interval
Move the adjustment of a new open interval that is enclosed by the
current open interval into the validation processing, where the other
overlap resolution takes place.

This will allow the start command to honor the :adjust flag when
starting a new interval that predates the current open interval.

Closes #326

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-12 12:27:31 +02:00
Thomas Lauf
1c1066ae6c Adapt standard overlap resolution
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-12 12:18:54 +02:00
Shaun Ruffell
4aacba47df CmdStart: Do not assume :all hint means now
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-07-08 21:28:41 +02:00
Shaun Ruffell
6a52a412ba CmdStart: Do not silently fail if tags match
It was possible previously to start an interval with a filter earlier
than the current filter, and if the tags matched, the command would
report success without actually moving the start time.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-07-08 21:28:41 +02:00
Shaun Ruffell
356f20c9de Remove getOverlaps function
Since the Intervals are all in order, we can use getTracked directly to
get overlapping intervals without the need to copy the Intervals into
another vector.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-07-08 21:28:41 +02:00