Skip to content

Commit 4f4c326

Browse files
committed
changelog-entry: rename from changelog-gen, update README, add --dir flag
1 parent db75d7b commit 4f4c326

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
lines changed

cmd/changelog-entry/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# changelog-entry
2+
3+
`changelog-entry` is a command that will generate a changelog entry based on the information passed and the information retrieved from the Github repository.
4+
5+
The default changelog entry template is embedded from [`changelog-entry.tmpl`](changelog-entry.tmpl) but a path to a custom template can also can be passed as parameter.
6+
7+
The type parameter can be one of the following:
8+
* bug
9+
* note
10+
* enhancement
11+
* new-resource
12+
* new-datasource
13+
* deprecation
14+
* breaking-change
15+
* feature
16+
17+
## Usage
18+
19+
```sh
20+
$ changelog-entry -type improvement -subcategory monitoring -description "optimize the monitoring endpoint to avoid losing logs when under high load"
21+
```
22+
23+
If parameters are missing the command will prompt to fill them, the pull request number is optional and if not provided the command will try to guess it based on the current branch name and remote if the current directory is in a git repository.
24+
25+
## Output
26+
27+
``````markdown
28+
```release-note:improvement
29+
monitoring: optimize the monitoring endpoint to avoid losing logs when under high load
30+
```
31+
``````
32+
33+
Any failures will be logged to stderr. The entry will be written to a file named `{PR_NUMBER}.txt`, in the current directory unless an output path is specified.
File renamed without changes.

cmd/changelog-gen/main.go renamed to cmd/changelog-entry/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/hashicorp/go-changelog"
1313
"github.com/manifoldco/promptui"
1414
"os"
15+
"path"
1516
"regexp"
1617
"strings"
1718
"text/template"
@@ -39,7 +40,7 @@ func main() {
3940
fmt.Fprintln(os.Stderr, err)
4041
os.Exit(1)
4142
}
42-
var subcategory, changeType, description, changelogTmpl, url string
43+
var subcategory, changeType, description, changelogTmpl, dir, url string
4344
var pr int
4445
var Url bool
4546
flag.BoolVar(&Url, "add-url", false, "add GitHub issue URL (omitted by default due to formatting in changelog-build)")
@@ -48,6 +49,7 @@ func main() {
4849
flag.StringVar(&changeType, "type", "", "the type of change")
4950
flag.StringVar(&description, "description", "", "the changelog entry content")
5051
flag.StringVar(&changelogTmpl, "changelog-template", "", "the path of the file holding the template to use for the changelog entries")
52+
flag.StringVar(&dir, "dir", "", "the relative path from the current directory of where the changelog entry file should be written")
5153
flag.Parse()
5254

5355
if pr == -1 {
@@ -128,7 +130,8 @@ func main() {
128130
if err != nil {
129131
os.Exit(1)
130132
}
131-
filepath := fmt.Sprintf("%s/%d.txt", pwd, pr)
133+
filename := fmt.Sprintf("%d.txt", pr)
134+
filepath := path.Join(pwd, dir, filename)
132135
err = os.WriteFile(filepath, buf.Bytes(), 0644)
133136
if err != nil {
134137
os.Exit(1)

cmd/changelog-gen/README.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)