Skip to content

Commit fefc894

Browse files
committed
docs: add advanced cases to the manual
1 parent 51409cc commit fefc894

File tree

1 file changed

+117
-3
lines changed

1 file changed

+117
-3
lines changed

docs/manual.md

Lines changed: 117 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
- [generate](#generate)
1717
- [release](#release)
1818
- [Advanced](#advanced)
19+
- [Selective Log Ranges](#selective-log-ranges)
20+
- [From a different repo](#from-a-different-repo)
21+
- [Categorize](#categorize)
1922
- [CLI](#cli)
2023

2124
<h3 id="basics">Basics</h3>
@@ -70,8 +73,21 @@ The behaviour of the `generate` command is like so
7073
eg: v0.0.2 -> HEAD, v0.0.1 -> SOMEHASH, would give you the commits between
7174
both the tags.
7275

73-
This is the default behavior of commitlog and can be changed by passing various
74-
flags which you'll read about soon.
76+
The default behaviour of **_commitlog_** is to print to the stdout of your
77+
terminal which might not be what you wish to do.
78+
79+
So, if you wish to ever write to a file , you can use the `--out FILE` flag to
80+
write the output to a file instead.
81+
82+
```sh
83+
$ commitlog g -o ./CHANGELOG.md
84+
```
85+
86+
> **Note**: commitlog will overwrite the file with the new output, make sure you
87+
> create a backup of the file when working with this.
88+
89+
> **Note**: In coming versions an append mode will be added to the CLI to avoid
90+
> having to deal with this manually
7591
7692
<h4 id="release">release</h3>
7793

@@ -136,7 +152,105 @@ $ commitlog r --patch --commit --push
136152

137153
<h3 id="advanced">Advanced</h3>
138154

139-
**TBD**
155+
These are not really hard to guess or achieve but are in the advanced section as
156+
this isn't something a beginner user might need to mess with. If you have other
157+
use cases that you feel like should be added here, raise a issue.
158+
159+
<h4 id="selective-log-ranges">Selective Log Ranges</h4>
160+
There's enough cases where the entire history between the tags makes no sense. You might just want a specific set of commits and this is very easy to do with commitlog
161+
162+
```sh
163+
$ commitlog g --start HEAD --end HEAD~3
164+
# would return the last 3 commits
165+
```
166+
167+
And as you might have understood, commitlog does work with git's revision system
168+
so you can reuse git's own revision pointers as needed. Though it's mostly
169+
easier to just use the HASH since, finding the hashes in `git log` is easier
170+
than finding the number you have to type after the `HEAD~`
171+
172+
<h4 id="from-a-different-repo">From a different repo</h4>
173+
A lot more often you might need to generate logs for a sub-repo when working with a huge multirepo folder which a lot of sub-modules and switching worktree for the changelog might not be something you wish to do.
174+
175+
In cases like these the `-p` or `--path` flag can be used with the `generate`
176+
flag
177+
178+
```sh
179+
$ commitlog g -p ./sub/module -s HEAD~3
180+
# would return the commits from HEAD~3 to the next tag or end of all commits.
181+
```
182+
183+
<h4 id="categorize">Categorize</h4>
184+
You wouldn't be using commitlog otherwise so this obviously has to exist.
185+
186+
As for why is this turned off by default? I just don't use commit standards and
187+
mostly just need the commits between tags and very rarely need the categories to
188+
help me but doesn't change the fact that someone else might need it.
189+
190+
So, how does commitlog categorize? using regex's , or more like comma seperated
191+
regex's.
192+
193+
The implementation approach might bring some issue but I'm going to wait for
194+
them instead of over fixing something that might never really happen.
195+
196+
Anyway, a simple example for a non-scoped commitlint styled categorization would
197+
look something like this .
198+
199+
```sh
200+
$ commitlog g --categories="feat:,fix:"
201+
```
202+
203+
**Output:**
204+
205+
```md
206+
## feat:
207+
110c9b260e6de1e2be9af28b3592c373ab6fc501 feat: handling for pre increment
208+
209+
9080580575d3579b3d11dd114830eb128f0c8130 feat: releaser base maj,min,patch setup
210+
211+
b513e53cbbc30e5b667fbba373b9589911a47ac0 feat: generator subcommand implementation
212+
213+
## fix:
214+
5bafe9d105298001707c7c816e60d3ef0257a816 fix: tag creation
215+
```
216+
217+
This could be made a little more neater using a better regex like so
218+
219+
```sh
220+
$ commitlog g --categories="^feat,^fix"
221+
```
222+
223+
**Output**:
224+
225+
```md
226+
## ^feat
227+
e0ce9c693c554158b7b4841b799524164d9c3e83 feat(releaser): add init and pre-tag handlers
228+
229+
110c9b260e6de1e2be9af28b3592c373ab6fc501 feat: handling for pre increment
230+
231+
9080580575d3579b3d11dd114830eb128f0c8130 feat: releaser base maj,min,patch setup
232+
233+
b513e53cbbc30e5b667fbba373b9589911a47ac0 feat: generator subcommand implementation
234+
235+
## ^fix
236+
5bafe9d105298001707c7c816e60d3ef0257a816 fix: tag creation
237+
238+
540bb3d7419aab314fdb999dd57eeac3c53f5fad fix doc generation
239+
240+
87d40ddbd463ad71b3af8b7edb8ac8176ecbf2f5 fix tests for new param
241+
```
242+
243+
As visible, you find more commits in the 2nd one since the regex matches more
244+
cases and gives you more information. You are free to modify these to make them
245+
work with other patterns that you might follow.
246+
247+
Also the titles are going to be the regex's you pass. A future version will add
248+
a way for you to add label's to the regex though that's a little harder to
249+
achieve without making the flags very verbose so I've avoided it for now.
250+
251+
> **Note**: This is the initial implementation of this and might change in a
252+
> future major version since this flag feels a little more frictional than the
253+
> other approaches I have in mind. Feel free to recommend other ways to do this.
140254
141255
<h3 id="cli">CLI</h3>
142256

0 commit comments

Comments
 (0)