git-semver-tagger 2.2.2 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -110,7 +110,7 @@ The `.tagger` file supports these fields:
110
110
  - `versionRegex`: Unified regex with named groups (major, minor, patch, none). Overrides individual regex patterns if set.
111
111
  - `userName`: Git user name for creating tags (defaults to git config)
112
112
  - `userEmail`: Git user email for creating tags (defaults to git config)
113
- - `warningsAsErrors`: Treat warnings as errors (exit non-zero) (default: false)
113
+ - `warningsAsErrors`: Enable strict mode - treat warnings as errors (exit non-zero) (default: false). See [Warnings and Strict Mode](#warnings-and-strict-mode) for details.
114
114
 
115
115
  **Note:** Command-line options always override `.tagger` file settings.
116
116
 
@@ -247,6 +247,100 @@ if [ "$STATUS" = "error" ]; then
247
247
  fi
248
248
  ```
249
249
 
250
+ ## Warnings and Strict Mode
251
+
252
+ Tagger emits warnings to stderr when it detects potentially risky conditions. By default, warnings don't fail the build (exit 0), but you can enable strict mode to treat warnings as errors.
253
+
254
+ ### Warning Classes
255
+
256
+ #### Deprecation Warnings
257
+ Issued when using deprecated flags or options:
258
+
259
+ ```
260
+ ⚠️ --disable-detached is deprecated and will be removed in a future version. Use --allow-detached-head=false instead.
261
+ ```
262
+
263
+ **Cause:** Using old CLI syntax that's scheduled for removal.
264
+
265
+ **Action:** Update your commands or config files to use the replacement option.
266
+
267
+ #### Release Risk Warnings
268
+ Issued when potentially unsafe operations are explicitly allowed:
269
+
270
+ ```
271
+ ⚠️ Running with allowDetachedHead on release branch. This may produce inconsistent versions if tags are not synchronized.
272
+ ```
273
+
274
+ **Cause:** Using `--allow-detached-head` on a release branch in detached HEAD state.
275
+
276
+ **Action:** Consider whether detached HEAD is appropriate for your workflow. For CI builds on release branches, this usually indicates a configuration issue.
277
+
278
+ #### Policy Violation Warnings (tag command)
279
+ The `tag` command issues warnings (not errors) when it cannot create a tag due to policy constraints:
280
+
281
+ ```
282
+ ⚠️ Cannot create tag: not on release branch 'main' (current branch: feature/xyz)
283
+ ```
284
+
285
+ **Cause:** Attempting to create a release tag from a non-release branch, a commit that's already tagged, or a snapshot version.
286
+
287
+ **Action:** Switch to the release branch, use `--release-branch` with the correct branch name, or adjust your tagging workflow.
288
+
289
+ ### Strict Mode (warningsAsErrors)
290
+
291
+ Enable strict mode to fail builds when warnings are present. This is useful for CI/CD pipelines where you want to enforce clean execution.
292
+
293
+ **Command-line flag:**
294
+ ```bash
295
+ tagger calculate-version --warnings-as-errors
296
+ tagger tag --version 1.2.3 --warnings-as-errors
297
+ ```
298
+
299
+ **Configuration file:**
300
+ ```json
301
+ {
302
+ "warningsAsErrors": true
303
+ }
304
+ ```
305
+
306
+ **Behavior changes with strict mode enabled:**
307
+
308
+ 1. **Exit code**: Changes from 0 to 1 when warnings are present
309
+ 2. **JSON output**: `calculate-version` returns error status instead of success when warnings escalate:
310
+ ```json
311
+ {
312
+ "status": "error",
313
+ "error": "Warnings treated as errors",
314
+ "code": "WARNINGS_AS_ERRORS",
315
+ "warnings": [
316
+ "Running with allowDetachedHead on release branch..."
317
+ ]
318
+ }
319
+ ```
320
+ 3. **Stderr diagnostics**: Warnings remain visible for troubleshooting
321
+
322
+ **CI integration example:**
323
+ ```bash
324
+ # Strict mode catches deprecation warnings before they become breaking changes
325
+ tagger calculate-version --warnings-as-errors --format=json > version.json
326
+
327
+ if [ $? -ne 0 ]; then
328
+ echo "Version calculation failed or warnings present:"
329
+ cat version.json | jq -r '.error, .warnings[]?'
330
+ exit 1
331
+ fi
332
+ ```
333
+
334
+ **When to use strict mode:**
335
+ - Production CI/CD pipelines where warnings indicate configuration drift
336
+ - During migration from deprecated options (fail fast on old syntax)
337
+ - When enforcing "clean build" policies across teams
338
+
339
+ **When NOT to use strict mode:**
340
+ - Local development workflows where warnings are informational
341
+ - Gradual rollout of new configuration options
342
+ - When using `allowDetachedHead` intentionally and warnings are expected
343
+
250
344
  ## Common Errors and Troubleshooting
251
345
 
252
346
  ### Lightweight Tags