Skip to main content

Module editor

Module editor 

Source
Expand description

$EDITOR / $VISUAL spawn helper for mkit commit.

Behaviour:

  • Honour $GIT_EDITOR first, then $EDITOR, then $VISUAL.
  • Fall back to vi on Unix / notepad on Windows when no env var is set, so mkit commit works out-of-the-box.
  • Write template to a tempfile, spawn the editor, wait, read the file back, strip any line whose first non-whitespace byte is #, and return the trimmed message.

Constants§

COMMIT_EDITMSG_TEMPLATE
Template rendered into the tempfile before spawning the editor.
MAX_COMMIT_MSG_BYTES
Maximum commit-message file size read back from the editor (1 MiB).

Functions§

spawn_editor
Spawn the user’s editor on a tempfile pre-populated with template, then read the file back, strip #-comment lines, and return the trimmed result.
strip_comments_and_trim
Strip all lines whose first non-whitespace byte is #, then trim trailing whitespace.