|
1 | | -# Shell |
2 | | - |
3 | | -Bash scripts around this project, to be used instead of as a VS Code extension. **This area is not complete and is still experimental.** |
4 | | - |
5 | | -Note: All the scripts in this directory are named with dashes and not underscores, to match the Git hook filenames convention. |
6 | | - |
7 | | - |
8 | | -## Samples |
9 | | - |
10 | | -Archive of shell scripts for reference. These are used in the early development of the project but are not actively used. |
11 | | - |
12 | | -- [count-files.sh](count-files.sh) |
13 | | -- [sample.sh](sample.sh) |
14 | | -- [simple-hook.sh](simple-hook.sh) |
15 | | - |
16 | | - |
17 | | -## Autofill scripts |
18 | | - |
19 | | -These are shell scripts to integrate with the JS scripts in this project, as an alternative to using, VS Code so I can use it any terminal and in other IDEs with their terminals. And if I stop using VS Code completely I can keep using the core at least in a terminal. |
20 | | - |
21 | | -- [autofill-hook.sh](autofill-hook.sh) |
22 | | -- [autofill.sh](autofill.sh) |
23 | | - |
24 | | -They are not complete but work as a POC for using the core logic outside project outside of VS Code as Git hook. |
25 | | - |
26 | | -### Dev notes |
27 | 1 |
|
28 | | -Remember to **compile** the TS to JS before running this script to get the latest changes. Or use a pre-compiled script. |
29 | | - |
30 | | -#### Purpose |
31 | | - |
32 | | -This script should be used as an **alternative** to using VS Code itself to handle your commit messages, as VS Code does not support a hook properly when going through the UI box (it actually **ignores** any message you type in and uses its own generated message from the hook). |
33 | | - |
34 | | -But, if you don't use it as an actual hook, there is an alternative flow that doesn't mess with VS Code. You can use the other script and set up a Git alias (which can be used across projects without setting a hook even). |
35 | | - |
36 | | -Sample output: |
37 | | - |
38 | | -```console |
39 | | -$ ./shell/autofill.sh |
40 | | -chore: update settings.json |
41 | | -$ ./shell/autofill.sh |
42 | | -update 11 files |
43 | | -``` |
44 | | - |
45 | | -Use it with Git. This uses the tool to generate a message and pass it as the Git commit message, but forcing edit mode so you can override it. |
46 | | - |
47 | | -```sh |
48 | | -$ git commit --edit -m "$(shell/autofill.sh)" |
49 | | -``` |
50 | | - |
51 | | -Move the script to a `bin` executables directory so you can run it from anywhere. |
52 | | - |
53 | | -```sh |
54 | | -$ cp autofill.sh /usr/local/bin |
55 | | -``` |
56 | | - |
57 | | -TODO: |
58 | | - |
59 | | -- [ ] Where to put the Node script so it can reference it. |
60 | | -- [ ] Windows support |
61 | | -- [ ] How to automated the install process for upgrades. Maybe the JS + shell script as NPM package or at least on GitHub with cURL install. |
62 | | -- [ ] Figure out how to switch between staged and not, with `--cached`. Like passing a param to the shell script and having two aliases. Or to have it as pass of the shell script to fallback to all if anything is staged. Or just control with filenames e.g. `git c .` or `git c package*` - oh wait, the shell script doesn't look at what is passed to `git commit`, only what is staged or not. |
| 2 | +# Shell |
63 | 3 |
|
64 | | -#### Alias |
| 4 | +See [acm-hook.sh](acm-hook.sh). |
65 | 5 |
|
66 | | -Set this up in git config aliases as `c` or something. If this was in a _bin_ directory, or used with an absolute path to the script. |
| 6 | +A CLI script that bypasses using VS Code or an extension. |
| 7 | +It will get output from Git, send it to Node CLI entry-point tool and print |
| 8 | +it. This can be used as part of Git commit message hook flow (pre-commit hook). |
67 | 9 |
|
68 | | -```toml |
69 | | -[alias] |
70 | | - c = '! git commit --edit -m "$(autofill.sh)"' |
71 | | -``` |
72 | 10 |
|
73 | | -Then instead of `git commit`, you can do: |
| 11 | +## Setup |
74 | 12 |
|
75 | | -```sh |
76 | | -$ git c |
| 13 | +If you want to use the hook: |
77 | 14 |
|
78 | | -$ git c foo.txt |
79 | | -``` |
| 15 | +1. Follow instructions to install the TS command globally as per [src/cli/README.md](/src/cli/README.md) |
| 16 | +1. Install the pre-commit hook. |
| 17 | + ```sh |
| 18 | + $ cp shell/acm-hook.sh YOUR_PROJECT/.hooks/pre-commit |
| 19 | + $ chmod +x YOUR_PROJECT/.hooks/pre-commit |
| 20 | + ``` |
80 | 21 |
|
81 | | -#### TODO |
| 22 | +## Debugging |
82 | 23 |
|
83 | | -- [ ] For now this points to the output directory so it limited in real world use. This is a stepping |
84 | | -stone. But ideally the JS files can be copied outside of this project to a central location (maybe |
85 | | -with a `bin` entry point). And the SH script can be added to an individual project in `.git/hooks` dir as `prepare-commit-msg`. |
86 | | -- [ ] When using this as a hook, consider reading from the **existing** commit message file in the case |
87 | | -of template, so it that can be passed on. |
88 | | -- [ ] Add a flag for staged to get `--cached` flag. |
| 24 | +Optionally add a `-p` debug flag to print without writing to a file. This |
| 25 | +makes it easy to debug the script outside a Git commit hook flow. |
0 commit comments