|
1 | 1 | # Commit Message Syntax for Version Bumping |
2 | 2 |
|
3 | | -Prospector can automatically bump versions based on keywords in commit messages. This provides fine-grained control over versioning without requiring git tags for every release. |
| 3 | +Prospector can automatically bump versions based on simple keywords in commit messages. This provides fine-grained control over versioning without requiring git tags for every release. |
4 | 4 |
|
5 | 5 | ## Supported Patterns |
6 | 6 |
|
7 | 7 | ### Major Version Bumps |
8 | 8 |
|
9 | | -Patterns that trigger a **major** version bump (e.g., `1.2.3` → `2.0.0`): |
10 | | - |
11 | | -- `[major]` - Explicit major bump marker |
12 | | -- `+semver: major` - Semantic version annotation |
13 | | -- `BREAKING CHANGE` - Conventional commits breaking change |
14 | | -- `BREAKING-CHANGE` - Alternative format |
| 9 | +Use `[major]` to trigger a **major** version bump (e.g., `1.2.3` → `2.0.0`): |
15 | 10 |
|
16 | 11 | **Examples:** |
| 12 | + |
17 | 13 | ```bash |
18 | 14 | git commit -m "[major] Complete API redesign" |
19 | | -git commit -m "+semver: major - Removed legacy endpoints" |
20 | | -git commit -m "refactor: BREAKING CHANGE: changed authentication flow" |
| 15 | +git commit -m "[major] Remove deprecated endpoints" |
| 16 | +git commit -m "Refactor authentication system [major]" |
21 | 17 | ``` |
22 | 18 |
|
23 | 19 | ### Minor Version Bumps |
24 | 20 |
|
25 | | -Patterns that trigger a **minor** version bump (e.g., `1.2.3` → `1.3.0`): |
26 | | - |
27 | | -- `[minor]` - Explicit minor bump marker |
28 | | -- `+semver: minor` - Semantic version annotation |
29 | | -- `feat:` - Conventional commits feature |
30 | | -- `feature:` - Alternative feature marker |
| 21 | +Use `[minor]` to trigger a **minor** version bump (e.g., `1.2.3` → `1.3.0`): |
31 | 22 |
|
32 | 23 | **Examples:** |
| 24 | + |
33 | 25 | ```bash |
34 | 26 | git commit -m "[minor] Add user dashboard" |
35 | | -git commit -m "feat: implement dark mode" |
36 | | -git commit -m "feature: add export to CSV functionality" |
37 | | -git commit -m "+semver: minor - new reporting module" |
| 27 | +git commit -m "[minor] Implement dark mode" |
| 28 | +git commit -m "Add export to CSV functionality [minor]" |
38 | 29 | ``` |
39 | 30 |
|
40 | 31 | ### Patch Version Bumps |
41 | 32 |
|
42 | | -Patterns that trigger a **patch** version bump (e.g., `1.2.3` → `1.2.4`): |
43 | | - |
44 | | -- `[patch]` - Explicit patch bump marker |
45 | | -- `+semver: patch` - Semantic version annotation |
46 | | -- `fix:` - Conventional commits fix |
47 | | -- `bugfix:` - Alternative fix marker |
| 33 | +Use `[patch]` to trigger a **patch** version bump (e.g., `1.2.3` → `1.2.4`): |
48 | 34 |
|
49 | 35 | **Examples:** |
| 36 | + |
50 | 37 | ```bash |
51 | 38 | git commit -m "[patch] Update dependencies" |
52 | | -git commit -m "fix: resolve login timeout issue" |
53 | | -git commit -m "bugfix: correct date formatting" |
54 | | -git commit -m "+semver: patch - minor UI tweaks" |
| 39 | +git commit -m "[patch] Fix login timeout issue" |
| 40 | +git commit -m "Correct date formatting [patch]" |
| 41 | +``` |
| 42 | + |
| 43 | +### Explicit Version Setting |
| 44 | + |
| 45 | +Use `[version:x.y.z]` or `[v:x.y.z]` to set an **exact version**: |
| 46 | + |
| 47 | +**Examples:** |
| 48 | + |
| 49 | +```bash |
| 50 | +git commit -m "[version:1.5.0] Release version 1.5.0" |
| 51 | +git commit -m "[v:2.0.0] Major release" |
| 52 | +git commit -m "Prepare for release [version:1.2.3]" |
55 | 53 | ``` |
56 | 54 |
|
| 55 | +**Note:** When an explicit version is set, it takes precedence over any bump indicators. This is useful for: |
| 56 | + |
| 57 | +- Aligning with external version requirements |
| 58 | +- Jumping to a specific version number |
| 59 | +- Resetting version after major refactoring |
| 60 | + |
57 | 61 | ### No Explicit Bump |
58 | 62 |
|
59 | 63 | Commits without bump indicators fall back to the default behavior (commit count): |
60 | 64 |
|
61 | 65 | **Examples:** |
| 66 | + |
62 | 67 | ```bash |
63 | | -git commit -m "chore: update README" |
64 | | -git commit -m "docs: improve API documentation" |
65 | | -git commit -m "style: format code" |
66 | | -git commit -m "test: add unit tests" |
| 68 | +git commit -m "Update README" |
| 69 | +git commit -m "Refactor internal code" |
| 70 | +git commit -m "Add comments" |
67 | 71 | ``` |
68 | 72 |
|
69 | 73 | ## Priority and Accumulation |
70 | 74 |
|
71 | 75 | ### Priority Order |
72 | 76 |
|
73 | | -When a commit contains multiple patterns, **only the highest priority** bump is counted: |
| 77 | +Patterns are evaluated in this priority order: |
74 | 78 |
|
75 | | -1. **Major** (highest priority) |
76 | | -2. **Minor** |
77 | | -3. **Patch** (lowest priority) |
| 79 | +1. **Explicit version** (highest priority - `[version:x.y.z]`) |
| 80 | +2. **Major** (`[major]`) |
| 81 | +3. **Minor** (`[minor]`) |
| 82 | +4. **Patch** (`[patch]`) |
| 83 | + |
| 84 | +**Examples:** |
78 | 85 |
|
79 | | -**Example:** |
80 | 86 | ```bash |
81 | | -# This commit only counts as a major bump, not major + minor |
82 | | -git commit -m "feat: BREAKING CHANGE: new authentication system" |
| 87 | +# Explicit version takes precedence over everything |
| 88 | +git commit -m "[major] [version:3.5.0] Release 3.5.0" # Results in 3.5.0 |
| 89 | + |
| 90 | +# Only the highest bump counts per commit |
| 91 | +git commit -m "[major] [minor] Big change" # Counts as major only |
83 | 92 | ``` |
84 | 93 |
|
85 | 94 | ### Accumulation |
86 | 95 |
|
87 | 96 | Multiple commits can accumulate bumps: |
88 | 97 |
|
89 | 98 | **Scenario:** |
| 99 | + |
90 | 100 | ```bash |
91 | 101 | git tag v1.0.0 |
92 | | -git commit -m "feat: add feature A" # Minor bump |
93 | | -git commit -m "feat: add feature B" # Minor bump |
94 | | -git commit -m "fix: bug in feature A" # Patch bump |
| 102 | +git commit -m "[minor] Add feature A" |
| 103 | +git commit -m "[minor] Add feature B" |
| 104 | +git commit -m "[patch] Fix bug in feature A" |
95 | 105 | ``` |
96 | 106 |
|
97 | 107 | **Result:** Version `1.2.1` |
| 108 | + |
98 | 109 | - Started at `1.0.0` |
99 | 110 | - 2 minor bumps → `1.2.0` |
100 | 111 | - 1 patch bump → `1.2.1` |
101 | 112 |
|
| 113 | +### Explicit Version Override |
| 114 | + |
| 115 | +When an explicit version is set, it overrides all accumulated bumps: |
| 116 | + |
| 117 | +**Scenario:** |
| 118 | + |
| 119 | +```bash |
| 120 | +git tag v1.0.0 |
| 121 | +git commit -m "[minor] Add feature" # Would bump to 1.1.0 |
| 122 | +git commit -m "[version:2.5.0] Align with upstream" # Sets to 2.5.0 |
| 123 | +``` |
| 124 | + |
| 125 | +**Result:** Version `2.5.0` (explicit version used) |
| 126 | + |
102 | 127 | ### Version Reset Rules |
103 | 128 |
|
104 | 129 | When bumping major or minor versions, lower components reset to 0: |
105 | 130 |
|
106 | 131 | **Major bump:** |
| 132 | + |
107 | 133 | - `1.5.7` + major → `2.0.0` (minor and patch reset) |
108 | 134 |
|
109 | 135 | **Minor bump:** |
| 136 | + |
110 | 137 | - `1.5.7` + minor → `1.6.0` (patch resets) |
111 | 138 |
|
112 | 139 | **Patch bump:** |
| 140 | + |
113 | 141 | - `1.5.7` + patch → `1.5.8` (no reset) |
114 | 142 |
|
| 143 | +**Explicit version:** |
| 144 | + |
| 145 | +- `1.5.7` + `[version:3.2.1]` → `3.2.1` (exact version) |
| 146 | + |
115 | 147 | ## Customizing Patterns |
116 | 148 |
|
117 | 149 | You can customize the patterns programmatically: |
|
0 commit comments