I layered it in the following steps
parser is mainly to parse the input range
eg. HEAD~v1.0.0
/v2.0.0~v1.0.0
/770ed02~585445d
/HEAD~
/770ed02~v2.0.0
In this step, you need to determine the scope of the changelog to be generated
find their corresponding tags/commits.
The final interface output from parser
type Range struct {
Commit
*client.Tag
}
type Scope struct {
Start Range // The range start
End Range // The range end
Tags []*client.Tag // Tags included in the range
}
After we specify the scope, we need, in the entire scope, which ones involve tags/commits
At this step, we already have relevant data
- scope
- tags/commit of each scope
With this data, we can generate a template. But before that, for better abstraction, We introduce an intermediate context. The entire context describes a completed version information. Including version
/date
/commits
From the above scope, we convert it to a context array
With the above context array, we can easily render the template.
Up to this point, the role of generator is to generate templates and which template to generate.
- JSON
- Markdown
- PlainText
In this step we will format the output. For example, format markdown/json
Output content at this stage, it determines whether to output a file or stdout