-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Simon Kohlmeyer
committed
Dec 15, 2019
1 parent
5ec1fba
commit 4eaaad7
Showing
6 changed files
with
502 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.stack-work | ||
*.cabal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# git-comtemplate (https://github.com/voidus/git-comtemplate) | ||
|
||
Small utility that prepares commit templates with a story id and co-authors. | ||
|
||
Running any command with `-h` or without any arguments shows a help page, except | ||
`git comtemplate reset`, which will disable commit templates until another | ||
command is run again. | ||
|
||
## Who is this project for? | ||
|
||
Let's say you or your team want git commit messages that adhere to a consistent | ||
format. Typing it manually on each commit is error-prone and distracts you from | ||
the actual commit message. | ||
|
||
Enter git-comtemplate. When you start working on a story, use | ||
`git comtemplate story NICE-1` to set the story id and `git comtemplate authors | ||
fh jd` and get coding. When you call `git commit` later on, your editor will be | ||
pre-filled with the following message: | ||
|
||
``` | ||
NICE-1: | ||
Co-authored-by: Finn the Human <[email protected]> | ||
Co-authored-by: Jake the Dog <[email protected]> | ||
``` | ||
|
||
There is even a space after the colon: If you're using vim, you can just press | ||
A end start typing. | ||
|
||
*Slightest of Warnings*: `git-comtemplate` will overwrite your user | ||
`commit.template` setting. If you are using this for something else, this | ||
project might not work for you. Also, it will probably interact weirdly with | ||
other git commit templating tools. | ||
|
||
## Author initials | ||
|
||
The mapping of initials that you can specify to `git comtemplate authors` has to | ||
be maintained by hand. They are stored in `git-comtemplate/authors.dhall` in | ||
your user config directory | ||
([XDG_CONFIG_HOME](https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.6.html), | ||
should default to ~/.config/). | ||
If that sounds confusing, don't worry: Running `git comtemplate` will show you | ||
the full file names. | ||
|
||
The file is a [dhall config file](https://dhall-lang.org/), but don't worry, if | ||
you saw json or wrote some code before it should look familiar. | ||
|
||
To get you started, `git comtemplate exampleAuthorsFile` will create the file | ||
with some example data if it doesn't exist. | ||
|
||
## Building/Installing | ||
|
||
git-comtemplate is written in | ||
[Haskell](https://qph.fs.quoracdn.net/main-qimg-086fb2e3079bd6fc4045d4da907fa4f5.webp). | ||
If you want to learn about Haskell, [Learn You a Haskell for Great Good! | ||
](http://learnyouahaskell.com/) is a nice introduction and can be read online | ||
for free. | ||
|
||
This project uses [stack](https://haskellstack.org) as a build tool. Stack takes | ||
care of downloading the compiler and all that stuff for us. It should | ||
be available in major package repositories. Here are a few examples: | ||
|
||
<dl> | ||
<dt>MacOS (with [homebrew](https://brew.sh/))</dt> | ||
<dd>`brew install haskell-stack`</dd> | ||
<dt>Nix</dt> | ||
<dd>`nix-env -i stack`</dd> | ||
<dt>Arch Linux</dt> | ||
<dd>`pacman -S stack`</dd> | ||
</dl> | ||
|
||
When you have stack installed, open a shell in the project folder and execute | ||
`stack build`. It takes a while on the first run, but that should be it! | ||
|
||
Stack puts the binary in a bit of a weird place. The following command prints | ||
the full path to the binary: | ||
|
||
`echo "$PWD"/$(stack path --dist-dir)/build/git-comtemplate/git-comtemplate` | ||
|
||
Put it anywhere on your PATH and you will be able to call it as either | ||
`git-comtemplate` or `git comtemplate` | ||
|
||
## FAQ | ||
|
||
<dl> | ||
<dt>I changed my mind, how can I get rid of everything this did?</dt> | ||
<dd>Run `git comtemplate`. In the text, it mentions two directories, one for | ||
config (probably `~/.config/git-comtemplate`) and one for it's state | ||
(probably `~/.local/share/git-comtemplate`). Run `git comtemplate reset` (or | ||
unset the `commit.template` git setting yourself) and delete the two | ||
`git-comtemplate` folders and nothing will remain.</dd> | ||
<dt>This is way too much typing. Why are the names so long?</dt> | ||
<dd>You can use `git comtemplate s` instead of `... story` as well as `a` | ||
for `authors`. If you think `comtemplate` is too long, you can run `git | ||
config --global alias.c comtemplate` and use `git c s STORY-42`. | ||
<br> | ||
I personally don't bother: I only type this once or twice a day at most. | ||
🤷</dd> | ||
<dt>This is great, but I want to use a different template</dt> | ||
<dd>I am sure you have a valid reason, but I would rather not add the | ||
complexity of supporting different templates. The problem isn't so much the | ||
templating itself but the configuration around it. | ||
<br> | ||
Right now, `git-comtemplate` has very narrowly defined code paths, and | ||
I would prefer to keep it this way. Maybe you can fork this project? If you | ||
are ready to put a few minutes in, open an issue and we'll talk about it. | ||
</dl> | ||
|
||
|
||
## Licensing | ||
|
||
This application is licensed under the GNU General Public License version 3 or | ||
later. |
Oops, something went wrong.