|
| 1 | +# git-comtemplate (https://github.com/voidus/git-comtemplate) |
| 2 | + |
| 3 | +Small utility that prepares commit templates with a story id and co-authors. |
| 4 | + |
| 5 | +Running any command with `-h` or without any arguments shows a help page, except |
| 6 | +`git comtemplate reset`, which will disable commit templates until another |
| 7 | +command is run again. |
| 8 | + |
| 9 | +## Who is this project for? |
| 10 | + |
| 11 | +Let's say you or your team want git commit messages that adhere to a consistent |
| 12 | +format. Typing it manually on each commit is error-prone and distracts you from |
| 13 | +the actual commit message. |
| 14 | + |
| 15 | +Enter git-comtemplate. When you start working on a story, use |
| 16 | +`git comtemplate story NICE-1` to set the story id and `git comtemplate authors |
| 17 | +fh jd` and get coding. When you call `git commit` later on, your editor will be |
| 18 | +pre-filled with the following message: |
| 19 | + |
| 20 | +``` |
| 21 | +NICE-1: |
| 22 | +
|
| 23 | +Co-authored-by: Finn the Human <finn@thetreehouse.com> |
| 24 | +Co-authored-by: Jake the Dog <jake@also.thetreehouse.com> |
| 25 | +``` |
| 26 | + |
| 27 | +There is even a space after the colon: If you're using vim, you can just press |
| 28 | +A end start typing. |
| 29 | + |
| 30 | +*Slightest of Warnings*: `git-comtemplate` will overwrite your user |
| 31 | +`commit.template` setting. If you are using this for something else, this |
| 32 | +project might not work for you. Also, it will probably interact weirdly with |
| 33 | +other git commit templating tools. |
| 34 | + |
| 35 | +## Author initials |
| 36 | + |
| 37 | +The mapping of initials that you can specify to `git comtemplate authors` has to |
| 38 | +be maintained by hand. They are stored in `git-comtemplate/authors.dhall` in |
| 39 | +your user config directory |
| 40 | +([XDG_CONFIG_HOME](https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.6.html), |
| 41 | +should default to ~/.config/). |
| 42 | +If that sounds confusing, don't worry: Running `git comtemplate` will show you |
| 43 | +the full file names. |
| 44 | + |
| 45 | +The file is a [dhall config file](https://dhall-lang.org/), but don't worry, if |
| 46 | +you saw json or wrote some code before it should look familiar. |
| 47 | + |
| 48 | +To get you started, `git comtemplate exampleAuthorsFile` will create the file |
| 49 | +with some example data if it doesn't exist. |
| 50 | + |
| 51 | +## Building/Installing |
| 52 | + |
| 53 | +git-comtemplate is written in |
| 54 | +[Haskell](https://qph.fs.quoracdn.net/main-qimg-086fb2e3079bd6fc4045d4da907fa4f5.webp). |
| 55 | +If you want to learn about Haskell, [Learn You a Haskell for Great Good! |
| 56 | +](http://learnyouahaskell.com/) is a nice introduction and can be read online |
| 57 | +for free. |
| 58 | + |
| 59 | +This project uses [stack](https://haskellstack.org) as a build tool. Stack takes |
| 60 | +care of downloading the compiler and all that stuff for us. It should |
| 61 | +be available in major package repositories. Here are a few examples: |
| 62 | + |
| 63 | +<dl> |
| 64 | + <dt>MacOS (with [homebrew](https://brew.sh/))</dt> |
| 65 | + <dd>`brew install haskell-stack`</dd> |
| 66 | + <dt>Nix</dt> |
| 67 | + <dd>`nix-env -i stack`</dd> |
| 68 | + <dt>Arch Linux</dt> |
| 69 | + <dd>`pacman -S stack`</dd> |
| 70 | +</dl> |
| 71 | + |
| 72 | +When you have stack installed, open a shell in the project folder and execute |
| 73 | +`stack build`. It takes a while on the first run, but that should be it! |
| 74 | + |
| 75 | +Stack puts the binary in a bit of a weird place. The following command prints |
| 76 | +the full path to the binary: |
| 77 | + |
| 78 | +`echo "$PWD"/$(stack path --dist-dir)/build/git-comtemplate/git-comtemplate` |
| 79 | + |
| 80 | +Put it anywhere on your PATH and you will be able to call it as either |
| 81 | +`git-comtemplate` or `git comtemplate` |
| 82 | + |
| 83 | +## FAQ |
| 84 | + |
| 85 | +<dl> |
| 86 | + <dt>I changed my mind, how can I get rid of everything this did?</dt> |
| 87 | + <dd>Run `git comtemplate`. In the text, it mentions two directories, one for |
| 88 | + config (probably `~/.config/git-comtemplate`) and one for it's state |
| 89 | + (probably `~/.local/share/git-comtemplate`). Run `git comtemplate reset` (or |
| 90 | + unset the `commit.template` git setting yourself) and delete the two |
| 91 | + `git-comtemplate` folders and nothing will remain.</dd> |
| 92 | + <dt>This is way too much typing. Why are the names so long?</dt> |
| 93 | + <dd>You can use `git comtemplate s` instead of `... story` as well as `a` |
| 94 | + for `authors`. If you think `comtemplate` is too long, you can run `git |
| 95 | + config --global alias.c comtemplate` and use `git c s STORY-42`. |
| 96 | + <br> |
| 97 | + I personally don't bother: I only type this once or twice a day at most. |
| 98 | + 🤷</dd> |
| 99 | + <dt>This is great, but I want to use a different template</dt> |
| 100 | + <dd>I am sure you have a valid reason, but I would rather not add the |
| 101 | + complexity of supporting different templates. The problem isn't so much the |
| 102 | + templating itself but the configuration around it. |
| 103 | + <br> |
| 104 | + Right now, `git-comtemplate` has very narrowly defined code paths, and |
| 105 | + I would prefer to keep it this way. Maybe you can fork this project? If you |
| 106 | + are ready to put a few minutes in, open an issue and we'll talk about it. |
| 107 | +</dl> |
| 108 | + |
| 109 | + |
| 110 | +## Licensing |
| 111 | + |
| 112 | +This application is licensed under the GNU General Public License version 3 or |
| 113 | +later. |
0 commit comments