Skip to content

Feature: progress output during pre-commit/pre-push hook #36

Description

@0x4ce66f11

(Somewhat related to #20 but more specific for one use case.)
For the workflow:

  1. git commit (without -m)
  2. pre-commit hook
  3. edit long commit message

It is a bit awkward to look at a black screen while waiting to edit the commit message, especially if the hook takes a minute to run.
Some progress output while the hook executes would be nice to have.

Example idea with step 2 command 3 still in progress:

Step 1: checks  
  ├─ Command 1 .......................... [Ok] 500ms  
  ╰─ Cmd 2 .............................. [Ok] 8s90ms  
Step 2: unit tests  
  ├─ Command 1 .......................... [Ok] 1s345ms  
  ├─ A Very Long Command 2 .............. [Ok] 1m7s  
  ╰─ Command 3 ..........................  

With this format you could simply progressively print the output, without having to delete/update already printed output.

You could just print "├─ {command_name} ......" without a newline, where the dots represent the in progress state.
(calling io::stdout().flush() afterwards, print! & println are usually line buffered.)
Once the command is done you can print the success/failure and timings followed by the newline.
The dots would be used for alignment with command names of different length.

The -v flag could control whether to print only one line per step or one per command, but that would be just another optional a nice to have.

(If the steps/commands are executed in parallel, there would be need for some type of synchronisation. For example via sync::Barrier, thread::JoinHandle, sync::mpsc, or sync::Condvar)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions