Refactor: Commit message build, simplify Issue-ID handling#37
Merged
tykeal merged 1 commit intolfreleng-actions:mainfrom Nov 5, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR moves Issue-ID lookup logic from GitHub Actions workflow steps to Python code, simplifying the action and centralizing trailer management. The change eliminates the external json-key-value-lookup-action dependency and consolidates commit message trailer handling into a single function.
Key changes:
- Migrated Issue-ID JSON lookup from bash steps to Python (
_resolve_issue_id_from_jsonfunction) - Removed
ISSUE_ID_LOOKUPinput (boolean toggle) - now lookup happens automatically whenISSUE_ID_LOOKUP_JSONis provided - Created centralized
_build_commit_message_with_trailersfunction to handle all trailer ordering and insertion - Updated tests to verify lookup functionality is no longer in action steps
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/github2gerrit/cli.py | Added _resolve_issue_id_from_json function and --issue-id-lookup-json CLI parameter; integrated lookup into main flow |
| src/github2gerrit/core.py | Removed legacy _insert_issue_id_into_commit_message; added centralized _build_commit_message_with_trailers for consistent trailer management |
| src/github2gerrit/models.py | Added issue_id_lookup_json field to Inputs dataclass |
| action.yaml | Removed ISSUE_ID_LOOKUP input and JSON lookup steps; added GITHUB_ACTOR environment variable; disabled UV cache |
| .github/workflows/github2gerrit.yaml | Removed ISSUE_ID_LOOKUP input from workflow definitions |
| README.md | Updated documentation to reflect automatic lookup behavior and removed migration note |
| tests/*.py | Added issue_id_lookup_json="" to all test Inputs instantiations; updated action step tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Major Changes:
1. Centralized Commit Message Building
- Created _build_commit_message_with_trailers() as single source of truth
- Consolidated duplicate trailer logic from 3 separate code paths
- Now handles Issue-ID, Signed-off-by, Change-ID, and GitHub metadata
- Ensures consistent trailer ordering across all modes
(squash, single, PR-as-commit)
- Reduced code by ~200 lines, improved maintainability
2. Simplified Issue-ID Lookup
- Removed ISSUE_ID_LOOKUP input (auto-enabled when JSON provided)
- Moved JSON lookup logic from GitHub Actions to Python CLI
- Removed dependency on external json-key-value-lookup-action
- Added JSON validation with clear warning messages
- Simplified action.yaml by ~50 lines (removed 3 workflow steps)
3. Enhanced User Experience
- Added Issue-ID to configuration table output
- Added console feedback: "✅ Added Issue-ID {value} to commit message"
- Added warning output: "⚠️ Warning: Issue-ID JSON was not valid"
- Issue-ID now added in ALL modes (squash, single commits, USE_PR_AS_COMMIT)
4. Code Quality
- Fixed all pre-commit linting errors
- Added issue_id_lookup_json parameter to all test fixtures
- All tests passing with 67.2% coverage
- Updated README documentation
Signed-off-by: Matthew Watkins <[email protected]>
b5f9bfc to
accea35
Compare
tykeal
approved these changes
Nov 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Major Changes:
Centralized Commit Message Building
Simplified Issue-ID Lookup
Enhanced User Experience
Code Quality