|
1 | | -# changelog kata |
| 1 | +# Changelog kata |
2 | 2 |
|
3 | 3 | ## Description |
4 | | -This kata is about creating a changelog file for a project to track the changes |
5 | | -of a project automatically by versioning following [Semantic Versioning](https://semver.org/) and [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). The changelog file should be in the format of [keepachangelog.com](https://keepachangelog.com/en/1.0.0/). |
| 4 | +This kata is about creating a **system that handles automatically, from commits, a changelog file** for a project to track the changes |
| 5 | +of it. This changelog file has to follow the format of [keepachangelog.com](https://keepachangelog.com/en/1.0.0/). |
6 | 6 |
|
7 | | -## Requirements |
| 7 | +The system has to have the following **functionalities**: |
| 8 | +- Create a new changelog file with the first version of the project or unreleased changes. |
| 9 | +- Update the changelog file with new changes unreleased. |
| 10 | +- Create a new release with unreleased changes. |
| 11 | +- Update the changelog file with the new version and the changes of the new version aka new Release. |
| 12 | +- [Optional] Create the changelog file with all releases created. |
8 | 13 |
|
9 | | -### Calculate next version from Release Candidate a Current Release |
10 | | -A set of commits, since last Release, represents a Release Candidate. |
11 | 14 |
|
12 | | -From the Release Candidate and Current Release, calculate the next version following [Semantic Versioning](https://semver.org/). |
| 15 | +The automation must be done following the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) and [Semantic Versioning](https://semver.org/). |
13 | 16 |
|
14 | | -for example: |
15 | | -``` |
16 | | -from Current Release v1.0.0 |
17 | 17 |
|
18 | | -Release Candidate: |
19 | | -[ |
20 | | - Commit{type: "feat", description: "add new feature"}, |
21 | | - Commit{type: "fix", description: "fix bug"} |
22 | | -] |
| 18 | +## keepachangelog |
23 | 19 |
|
24 | | -calculateNextRelease(Release Candidate, Current Release) -> v1.1.0 |
25 | | -``` |
| 20 | +This format has got different sections that will be explained in the following sections. |
| 21 | + |
| 22 | +### Header |
26 | 23 |
|
27 | | -### Generate/Update changelog |
28 | | -Using the release candidate and the current release, generate or update the changelog file in the format of [keepachangelog.com](https://keepachangelog.com/en/1.0.0/). |
| 24 | +This is a fixed / No changable section at the top of the file and has the following content: |
29 | 25 |
|
30 | | -```markdow |
| 26 | +```markdown |
31 | 27 | # Changelog |
| 28 | + |
32 | 29 | All notable changes to this project will be documented in this file. |
33 | 30 |
|
34 | | -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
35 | | -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 31 | +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), |
| 32 | + [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and |
| 33 | + [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). |
| 34 | +``` |
| 35 | + |
| 36 | +### Unreleased changes section: |
| 37 | + |
| 38 | +This section accumulates all the changes that are **not released** yet. |
| 39 | + |
| 40 | +It has to be the first section among sections related a changes section of changes. |
| 41 | + |
| 42 | +The **purpose** is used to communicate how it will be the upcoming release. |
36 | 43 |
|
| 44 | +The section has the following format: |
| 45 | +```markdown |
| 46 | +## [Unreleased] |
| 47 | + |
| 48 | +<Changes> |
| 49 | + |
| 50 | +``` |
| 51 | + |
| 52 | +### Version Section |
| 53 | + |
| 54 | +This section has the changes of a specific version. |
| 55 | +The section has the following format: |
| 56 | +```markdown |
37 | 57 | ## [Version] - YYYY-MM-DD |
38 | | -### Added |
39 | | -- Details about new features or important additions. |
40 | 58 |
|
41 | | -### Changed |
42 | | -- Changes to existing features, performance improvements, or UI updates. |
| 59 | +<Changes> |
| 60 | +``` |
43 | 61 |
|
44 | | -### Deprecated |
45 | | -- Features that are still functional but are marked for removal in future releases. |
| 62 | +There will be zero, one o more than one version sections in the file. |
46 | 63 |
|
47 | | -### Removed |
48 | | -- Features that have been removed from the software. |
| 64 | +> [!IMPORTANT] |
| 65 | +> When there is more than one version section, the order has to be from the newest to the oldest |
49 | 66 |
|
50 | | -### Fixed |
51 | | -- Bug fixes or error corrections. |
52 | 67 |
|
53 | | -### Security |
54 | | -- Security-related changes (such as vulnerability patches or security improvements). |
| 68 | +### Compare Section |
55 | 69 |
|
56 | | -## [Unreleased] |
57 | | -- A list of future changes that have not yet been released. |
| 70 | +This section has a link to compare the current version with the previous one. |
| 71 | + |
| 72 | +For this case the are some special cases |
| 73 | +- The first version has to compare with the previous version. |
| 74 | +- The last version has to compare with the HEAD. |
| 75 | +- The other versions have to compare with the previous version. |
| 76 | + |
| 77 | +In addition, the link depends on the remote repository, so it has to be adapted to the specific one the user choose. |
58 | 78 |
|
| 79 | +In the following example that shows the format of the section, the link is for a github repository: |
| 80 | + |
| 81 | +```markdown |
59 | 82 | ## Compare |
60 | | -You can compare this version with the previous one or any other version using a version control link: |
61 | | -- [v1.0.0...v1.1.0](https://repository-url/compare/v1.0.0...v1.1.0) |
62 | 83 |
|
| 84 | +[unreleased]: https://repository-url/compare/[last-version]...HEAD |
| 85 | +[last-version]: https://repository-url/compare/[last-version]...[previous-version] |
| 86 | +[previous-version]: https://repository-url/compare/[first-version]...[previous-version] |
| 87 | +[first-version]: https://repository-url/releases/tag/[first-version] |
| 88 | +``` |
| 89 | + |
| 90 | +### Changes Sections |
| 91 | + |
| 92 | +The changes can be unreleased or versioned as previously it was mentioned. |
| 93 | +keepachangelog classifies changes in the following types: |
| 94 | +- **Added** for new features. |
| 95 | +- **Changed** for changes in existing functionality. |
| 96 | +- **Deprecated** for soon-to-be removed features. |
| 97 | +- **Removed** for now removed features. |
| 98 | +- **Fixed** for any bug fixes. |
| 99 | +- **Security** in case of vulnerabilities. |
| 100 | + |
| 101 | +these types have to follow the following format: |
| 102 | +```markdown |
| 103 | +### [type-of-change] |
| 104 | +- Details about the change. |
| 105 | +- and so on. |
| 106 | +``` |
| 107 | +> [!IMPORTANT] |
| 108 | +> When there are not changes of a specific type, the section has not to be created. |
| 109 | +
|
| 110 | + |
| 111 | +## Conventional Commits |
| 112 | + |
| 113 | +The convetional commit allows classify the changes in two ways: |
| 114 | +- How the commit wil change the current version of the project. |
| 115 | +- What is the type of change. |
| 116 | + |
| 117 | +So, it is a format created to standardize the commit messages and allow the automation of the versioning of the project. |
| 118 | + |
| 119 | +The format of the commit is the following: |
| 120 | + |
| 121 | +```markdown |
| 122 | +<type>[optional scope]: <description> |
| 123 | +``` |
| 124 | + |
| 125 | +For the system the type of the commit is the following: |
| 126 | +- feat: new feature |
| 127 | +- fix: bug fix |
| 128 | +- docs: documentation |
| 129 | +- style: formatting, missing semi colons, etc; no code change |
| 130 | +- refactor: refactoring production code |
| 131 | +- test: adding tests, refactoring test; no production code change |
| 132 | +- chore: updating build tasks, package manager configs, etc; no production code change |
| 133 | + |
| 134 | +The scope will not be used. |
| 135 | + |
| 136 | +Finally, to communicate the breaking changes, the commit has to have a special format: |
| 137 | +```markdown |
| 138 | +<type>!: <description> |
| 139 | +``` |
| 140 | + |
| 141 | +## Semantic Versioning |
| 142 | + |
| 143 | +The semantic versioning is a standard to versioning the software. It has the following format: |
| 144 | +```markdown |
| 145 | +<major>.<minor>.<patch> |
63 | 146 | ``` |
64 | 147 |
|
65 | | -## How to resolve the kata |
66 | | -s |
67 | | -No matter the language you choose, but you can select some of the approaches below: |
68 | | -- [Inside-Out TDD](/docs/inside-out-tdd.md) |
69 | | -- [Outside-In TDD](/docs/outside-in-tdd.md) |
| 148 | +The version has to be calculated following the following rules: |
| 149 | +- Major version is incremented when you make incompatible API changes. |
| 150 | +- Minor version is incremented when you add functionality in a backwards compatible manner. |
| 151 | +- Patch version is incremented when you make backwards compatible bug fixes. |
| 152 | + |
| 153 | +So, the system has to calculate the next version following the commits since the last release. |
| 154 | +The mapping between the commits and the semantic version change is the following: |
| 155 | + |
| 156 | +| Commit Type | Version Change | |
| 157 | +|-------------|----------------| |
| 158 | +| feat | Minor | |
| 159 | +| fix | Patch | |
| 160 | +| docs | None | |
| 161 | +| style | None | |
| 162 | +| refactor | None | |
| 163 | +| test | None | |
| 164 | +| chore | None | |
| 165 | +| <any>! | Major | |
| 166 | + |
| 167 | + |
| 168 | +Added for new features. |
| 169 | +Changed for changes in existing functionality. |
| 170 | +Deprecated for soon-to-be removed features. |
| 171 | +Removed for now removed features. |
| 172 | +Fixed for any bug fixes. |
| 173 | +Security in case of vulnerabilities. |
70 | 174 |
|
71 | 175 |
|
72 | 176 |
|
73 | | -## Acceptance Criteria |
74 | | -- The changelog file should be in the format of [keepachangelog.com](https://keepachangelog.com/en/1.0.0/). |
75 | | -- The changelog file should be generated or updated with the release candidate and the current release. |
76 | | -- The version should be calculated following [Semantic Versioning](https://semver.org/). |
77 | | -- The changelog file should have a section for each type of commit: Added, Changed, Deprecated, Removed, Fixed, Security. |
78 | | -- The changelog file should have a section for unreleased changes. |
79 | | -- The changelog file should have a section to compare the current version with the previous one. |
80 | | -- The changelog file should have a link to compare the current version with the previous one. |
| 177 | +## Example |
| 178 | + |
| 179 | +The following example shows a changelog file with two versions and unreleased changes. |
| 180 | + |
| 181 | +```markdown |
| 182 | + |
| 183 | +# Changelog |
| 184 | + |
| 185 | +All notable changes to this project will be documented in this file. |
| 186 | + |
| 187 | +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), |
| 188 | + [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and |
| 189 | + [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). |
| 190 | + |
| 191 | +## [Unreleased] |
| 192 | + |
| 193 | +### Added |
| 194 | +- New feature 3 |
| 195 | +- New feature 4 |
| 196 | + |
| 197 | +### Changed |
| 198 | +- Change 1 |
| 199 | + |
| 200 | + |
| 201 | +## [1.0.0] - 2021-01-01 |
| 202 | + |
| 203 | +### Added |
| 204 | +- New feature 2 |
| 205 | + |
| 206 | + |
| 207 | +## [0.1.0] - 2020-12-01 |
| 208 | + |
| 209 | +### Added |
| 210 | +- New feature 1 |
| 211 | + |
| 212 | + |
| 213 | +## Compare |
81 | 214 |
|
| 215 | +[unreleased]: https://repository-url/compare/1.0.0...HEAD |
| 216 | +[1.0.0]: https://repository-url/compare/1.0.0...0.1.0 |
| 217 | +[0.1.0]: https://repository-url/releases/tag/0.1.0 |
82 | 218 |
|
83 | | -## References |
84 | | -- [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) |
85 | | -- [Semantic Versioning](https://semver.org/) |
86 | | -- [keepachangelog.com](https://keepachangelog.com/en/1.0.0/) |
| 219 | +``` |
0 commit comments