git-time-metric / gtm

Simple, seamless, lightweight time tracking for Git
MIT License
973 stars 52 forks source link

`gtm commit` deletes pending time when a note for last commit already exists #104

Closed acuarica closed 4 years ago

acuarica commented 4 years ago

I would like to be able to track hours without actually committing (maybe code is not ready for commit and I spent a couple of hours reading a code base). I figured the command gtm commit should do the trick.

When I execute the command gtm commit -yes, I get the following message and the command exits with error code 1:

$ gtm commit -yes
note for '<SHA-1>' exists already

But the main issue is, that after executing gtm commit my pending data is gone, i.e., the gtm report command shows no new time added and gtm status resets.

Here is a full sequence of steps on how to reproduce the issue:

$ gtm report  # Shows last commit
7d50e9b <commit message>
Thu Apr 02 21:40:12 2020 +0200 notes Luigi

        1m  0s 100% [r] ../.git/modules/notes/COMMIT_EDITMSG
        1m  0s          notes [+1 -0 = 1] [60/hr]

$ gtm status. # Pending time with a couple of files

       24m 40s  91% [r] Terminal
        1m 50s   7% [r] TODOs.org
           30s   2% [r] Projects.org
       27m  0s          notes

$ gtm commit -yes # Run the aforementioned command
note for '7d50e9b9ce48f25273bd150c62e100c8d11dbfa9' exists already

$ gtm report # Same as first report, no pending time was added
7d50e9b <commit message>
Thu Apr 02 21:40:12 2020 +0200 notes Luigi

        1m  0s 100% [r] ../.git/modules/notes/COMMIT_EDITMSG
        1m  0s          notes [+1 -0 = 1] [60/hr]

$ gtm status # Pending time was reset, deleting time of corresponding files

        1m  0s 100% [r] Terminal
        1m  0s          notes

Am I doing something wrong? How is the gtm commit command should work exactly?

Just wondering, last commit for gtm was from last year, how active is the project? I'm asking because I really enjoy managing my time with it, and I would like to see it gaining more traction.

Anyways, thanks for this cool tool!

acuarica commented 4 years ago

Reading the Wiki found out this is exactly the expected behavior. Taken from the Wiki, Commit Time:

This is automatically called from the postcommit hook
Warning - any time logged will be cleared from your working directory

I'll close this issue.