Closed mpldr closed 2 years ago
I had this idea a long time ago, but no one has ever requested it and I myself don't write long commits too often. However, your request prompted me to investigate a little bit.
git var GIT_EDITOR
This command prints out the editor that git
is configured to use. This would be useful for this feature, granted you probably have that set to your own preference and we want to be considerate.
The git-commit
command has a very useful flag: -t
.
-t <file>, --template=<file>
When editing the commit message, start the editor with the contents in the given file. The
commit.template configuration variable is often used to give this option implicitly to the command. This
mechanism can be used by projects that want to guide participants with some hints on what to write in
the message in what order. If the user exits the editor without editing the message, the commit is
aborted. This has no effect when a message is given by other means, e.g. with the -m or -F options.
I think what you're asking is quite doable. It will be added in the next release.
All we need to do is:
/tmp
or something) with that title line at the top.git commit -t /tmp/sema-template-file.txt
.I think that's all there is to it.
I'd like to keep the default behaviour of sema
as is and allow you to use this feature with a -l | --long
flag. So you'll be doing
sema -pal
In future releases, I may add some way of configuring this behaviour. Maybe a config.sema
file like below that you can put at the root of your repo.
long: true
This bit from an ancient project of mine might be helpful: https://git.sr.ht/~poldi1405/bulkrename/tree/master/item/plan/edit.go#L11-37
(Please completely disregard everything else in this repo… this was a project for university that I really didnt care about.)
Hi, love the idea!
I just have a little problem: currently I can only write commit titles, not messages. Due to how I do stuff I usually add 2-20 lines of prose as well which I currently have to do separately which is a bit tedious. Would it be possible to open
$EDITOR
or something similar with the title prefilled and the ability to write some text below?