feat: Configurable environment identifiers#80
Conversation
Replaces hardcoded `test` and `uat` logic with dynamic environment support.
A `.git-tag-inc.json` or `.gittaginc.json` config can now be provided with an
`Envs` array to specify environment priorities and valid names. The system defaults
to `{"envs": ["test", "uat"]}` for backwards compatibility.
Fixes #1.
Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request introduces support for custom environment names in Git tags by loading configuration from JSON files and refactoring the tag structure and parsing logic to use dynamic environments instead of hardcoded 'test' and 'uat' values. The review feedback highlights critical concurrency issues, specifically data races when reading and writing the global ConfiguredEnvsMap map across parsing, comparison, and tests. Additionally, the reviewer recommends returning and handling errors in LoadConfig, normalizing environment names to lowercase, and escaping environment names with regexp.QuoteMeta to prevent potential regex compilation panics.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
- Handle non-NotExist errors from configuration loading in `main.go`. - Return errors from `LoadConfig` and normalize names to lowercase. - Synchronize reads to `ConfiguredEnvsMap` in `ParseTag`, `LessThan`, and `CommandsToFlags` with `parseTagReLock.RLock`. - Escape environment names via `regexp.QuoteMeta` in dynamic regex generation. - Fix concurrency issues in tests by wrapping config modifications with locks. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Replaces JSON configuration parsing with a simplified custom parser allowing syntax like `Envs: test & uat` or `Envs(test, uat)` alongside `# comments`. - Implements `FindConfig` to recursively check up the directory tree to locate `.git-tag-inc.conf` or `.gittaginc.conf`, matching standard `.git` directory behaviour. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Fixes all compiler errors related to the removal of `Test` and `Uat` fields across `tag_test.go`. - Implements comprehensive testing for the custom `LoadConfig` and `FindConfig` functionality utilizing `testdata/test_config.conf`. - Removes all extraneous build python scripts from workspace. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Changed the configuration parsing regex to split by `[\s,]+` instead of `[\s,&|]+` to avoid any potential ambiguity with bitwise operators. - Updated `testdata/test_config.conf` to reflect this new `,` separated syntax. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Removes the `Envs(test, uat)` parenthesis syntax as it is unnecessary. - Extracts `TestCustomEnvConfig` and `TestFindConfig` into `config_test.go` to cleanly separate testing responsibilities. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Config files are optional aids, so malformed contents should log a warning rather than crash the execution entirely. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
|
@jules I am expecting more tests to prove that it doesn't break the existing functionality, and auto detects well: |
Refactored |
- Refactored `FindConfig` and `LoadConfig` to accept `fs.FS` interfaces, decoupling config discovery from the host operating system. - Added comprehensive tests to `config_test.go` utilizing `testing/fstest.MapFS` to create virtual directory structures that accurately verify recursive config discovery without modifying local environments. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Drops `io/fs` from config discovery to support absolute directory paths via `os.Getwd()` without violating `fs.ValidPath` rules. - Implements robust local tests for file discovery using `t.TempDir()`. - Added a `-config` flag to strictly load a config and exit on failure. - Silenced non-critical warnings and limited auto-discovery to `.git-tag-inc.conf`. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
|
@jules 2 lint issues: |
Added proper error handling to |
- Handled the `os.MkdirAll` return value properly in `config_test.go`. - Explicitly dropped the error on `LoadConfig` fallback in `cmd/git-tag-inc/main.go` using `_ =` since warnings for the fallback were disabled. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Clean up leftover temporary script fix_config_fs.py. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
This submission resolves issue #1 by allowing the environment labels for tagging to be configured. The change dynamically generates the tag parsing regex based on the configuration and updates all tagging logic to use a unified
EnvNameandEnvinstead of hardcoded options.PR created automatically by Jules for task 16945033016421357920 started by @arran4