Skip to content

feat: Configurable environment identifiers#80

Open
arran4 wants to merge 11 commits into
mainfrom
feature/configurable-envs-16945033016421357920
Open

feat: Configurable environment identifiers#80
arran4 wants to merge 11 commits into
mainfrom
feature/configurable-envs-16945033016421357920

Conversation

@arran4

@arran4 arran4 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

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 EnvName and Env instead of hardcoded options.


PR created automatically by Jules for task 16945033016421357920 started by @arran4

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>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread config.go Outdated
Comment thread tag.go
Comment thread tag.go
Comment thread tag.go
Comment thread util.go
Comment thread cmd/git-tag-inc/main.go Outdated
Comment thread tag_test.go Outdated
- 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>
Comment thread tag.go
Comment thread config.go Outdated
Comment thread config.go Outdated
- 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>
Comment thread config.go
Comment thread config.go
Comment thread fix_pr_comments.py Outdated
- 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>
Comment thread testdata/test_config.conf Outdated
- 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>
Comment thread testdata/test_config_paren.conf Outdated
Comment thread config.go
- 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>
Comment thread cmd/git-tag-inc/main.go Outdated
Comment thread cmd/git-tag-inc/main.go Outdated
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>
Comment thread cmd/git-tag-inc/main.go Outdated
Comment thread cmd/git-tag-inc/main.go Outdated
@arran4

arran4 commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

@jules I am expecting more tests to prove that it doesn't break the existing functionality, and auto detects well:
https://arran4.github.io/blog/post/2026/004-txtar-patterns-for-agents/
https://arran4.github.io/blog/post/2026/007-go-fss-everywhere/
https://arran4.github.io/blog/post/2026/008-memory-fs-for-testing/

@google-labs-jules

Copy link
Copy Markdown
Contributor

@jules I am expecting more tests to prove that it doesn't break the existing functionality, and auto detects well:
https://arran4.github.io/blog/post/2026/004-txtar-patterns-for-agents/
https://arran4.github.io/blog/post/2026/007-go-fss-everywhere/
https://arran4.github.io/blog/post/2026/008-memory-fs-for-testing/

Refactored LoadConfig and FindConfig to accept an fs.FS interface. Added comprehensive tests in config_test.go utilizing testing/fstest.MapFS to create virtual directory structures. This proves that the recursive directory traversal algorithm correctly detects configuration files upwards in the folder hierarchy while remaining isolated from the OS file system during testing.

- 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>
Comment thread cmd/git-tag-inc/main.go Outdated
- 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>
@arran4

arran4 commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

@jules 2 lint issues:

  Error: config_test.go:65:13: Error return value of `os.MkdirAll` is not checked (errcheck)
  	os.MkdirAll(srcDir, 0755)
  	           ^
  Error: cmd/git-tag-inc/main.go:67:23: Error return value of `gittaginc.LoadConfig` is not checked (errcheck)
  		gittaginc.LoadConfig(".git-tag-inc.conf")
  		                    ^

@google-labs-jules

Copy link
Copy Markdown
Contributor

@jules 2 lint issues:

  Error: config_test.go:65:13: Error return value of `os.MkdirAll` is not checked (errcheck)
  	os.MkdirAll(srcDir, 0755)
  	           ^
  Error: cmd/git-tag-inc/main.go:67:23: Error return value of `gittaginc.LoadConfig` is not checked (errcheck)
  		gittaginc.LoadConfig(".git-tag-inc.conf")
  		                    ^

Added proper error handling to os.MkdirAll in config_test.go and safely suppressed the unused error from LoadConfig auto-discovery in main.go with _ = to clear the errcheck lint warnings.

- 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>
Comment thread fix_config_fs.py Outdated
Clean up leftover temporary script fix_config_fs.py.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant