Commit graph

2852 commits

Author SHA1 Message Date
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
Thomas Lauf
7bc511bc73 Update tests for TagInfoDatabase
- Add tests for JSON output
- Separate different test scenarios
- Optimize JSON output in `TagInfoDatabase::toJson ()`

- Closes #325

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-02 22:42:45 +02:00
Quazgar
ca10d52927 ENH: tags.data writes one entry per line.
This makes it easier to compare and merge the tags file from different machines.

Signed-off-by: Quazgar <quazgar@posteo.de>
2020-07-02 22:38:51 +02:00
Thomas Lauf
13a116a301 Update documentation of 'timew-continue'
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-02 19:59:47 +02:00
Thomas Lauf
d99872eb90 Finish implementation of 'continue by tag'
- This adds the last bits to the PR started by Christian Roesch:
- Some code formatting
- Specifying both id(s) and tag(s) is an error
- Clear range for tag filter: The range is meant to set the new interval's range, not the filter's
- Added tests
- Overhauled test using relative times and testing exported intervals instead of command line output
- Closes #241

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-02 19:59:47 +02:00
Christian Rösch
3def4b10c4 Refactor code as suggested and add tests. 2020-07-01 16:16:58 +02:00
Christian Rösch
f3280966e0 Allow continue by tag. 2020-07-01 16:16:58 +02:00
Thomas Lauf
6db29f1df5 Move overlap resolution from CmdContinue to function autoAdjust
- Only an open interval can truncate another open interval.
  Otherwise the `:adjust` hint has to be applied

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-01 08:12:04 +02:00
Thomas Lauf
c6598b9ac8 Convert to early return
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-30 21:17:51 +02:00
Thomas Lauf
07a6dfe313 Use functions is_started() and is_ended() instead of querying start/end directly
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-29 22:09:00 +02:00
Thomas Lauf
4637cd3d4e Do not manipulate filter in getTracked
- Filter shall be taken as is, not changed
- If there is a problem, the functions consuming the filter have to be adapted, not the filter

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-29 22:07:35 +02:00
Thomas Lauf
63f230013a Detect whether a date is meant as range
- Add DatetimeParser::parse_range: If a date contains no time, it is assumed to be a fixed range, else an open range starting at given datetime
- Add tests for summary with named dates 'yesterday' and 'today'
- Remove closing of filter in CmdSummary.cpp
- Closes #333

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-28 20:52:43 +02:00
Thomas Lauf
2906f36830 Add test for command summary with :all hint
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-22 22:21:27 +02:00
George Buckingham
90081afb97 Update docs links from taskwarrior.org to timewarrior.net
Signed-off-by: George Buckingham <george.buckingham@gmail.com>
2020-06-14 15:12:57 +02:00
Shaun Ruffell
59d0f1263f Mask signals while updating database
In order to keep the database consistent, we really want all the
AtomicFiles to be finalized as a group. This will prevent an inopportune
signal from interrupting this process.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-06-03 21:31:01 +02:00
Thomas Lauf
83ec55cdc6 Remove unused filter
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-03 18:44:36 +02:00
Thomas Lauf
c9eec956e4 Add hint :all
- Closes #206

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-03 18:44:36 +02:00
Thomas Lauf
6117ce1a84 Introduce default range parameter when requesting filter from CLI
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-03 17:47:14 +02:00
Thomas Lauf
7e11fde992 Remove template.t from test folder
- This file was development only, now any other test file can serve as template for new tests
- Closes #303

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-22 09:16:08 +02:00
Thomas Lauf
c71eeb6dfd Add DOM-query for ids
- Closes #126

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00
Thomas Lauf
2169e8e928 Add/update descriptive comments
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00
Thomas Lauf
a508dd21ea Get and use filter from CLI when processing DOM references
- Closes #188

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00
Thomas Lauf
13f1de2c49 Identify DOM references by their prefix ('dom.<...>') and mark them as such when analyzing the command line
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00
Thomas Lauf
9ae3ace109 Make getFilter(cli) a method of CLI 2020-05-10 21:44:30 +02:00