Feat: Implement fallback missing change creation#145
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements a fallback mechanism that allows GitHub2Gerrit to recover from scenarios where a previous run failed to create a corresponding Gerrit change. Previously, when an opened event failed and subsequent synchronize events tried to update a non-existent change, the tool would exit with an error. The fallback provides two recovery methods: a --create-missing CLI flag/action input and a PR comment command system using @github2gerrit create missing change.
Changes:
- Introduced an extensible PR command system with a registry-based architecture for parsing
@github2gerritdirectives from PR comments - Added
_should_create_missing()and_post_create_missing_notice()methods to the Orchestrator to detect and handle the fallback scenario - Modified the
execute()method to catch OrchestratorError during UPDATE operations and switch to CREATE mode when authorized via flag or comment
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/github2gerrit/pr_commands.py | New module implementing the extensible command parsing system with case-insensitive, alias-aware matching |
| tests/test_pr_commands.py | Comprehensive test suite covering command parsing, orchestrator integration, edge cases, and real-world regression scenarios |
| src/github2gerrit/core.py | Added fallback detection logic in _should_create_missing(), PR notification in _post_create_missing_notice(), and exception handling in execute() |
| src/github2gerrit/cli.py | Added --create-missing CLI option with environment variable support (G2G_CREATE_MISSING) |
| src/github2gerrit/models.py | Added create_missing boolean field to Inputs dataclass |
| action.yaml | Added CREATE_MISSING input for GitHub Actions workflows |
| README.md | Added comprehensive documentation for PR comment commands and the create missing change feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Provide fallback mechanisms for when a previous GitHub2Gerrit run failed to create a corresponding Gerrit change. Previously, in this scenario, the tool would attempt to update an existing Gerrit change, fail to find one, and exit with an error. Out fallback mechanism provides two invocation methods: - A new CLI flag/arg --create-missing and action input - Commenting on pull requests with @github2gerrit Adding this line as a comment on a pull request: @github2gerrit create missing change ...will trigger the creation of a new change, and prevent a failed update call, which would otherwise cause the workflow run to error. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
3913a4a to
83c77dd
Compare
Replace emoji characters that use variation selectors (U+FE0F) with single-codepoint alternatives to fix misaligned table borders and missing spaces in macOS Terminal.app: - Remove hardcoded clipboard prefix from progress tracker output - Replace checkbox with green tick in config display - Replace stopwatch with hourglass in timing display - Replace up arrow with magnifier for commit extraction - Replace clipboard with folder for local checkout step Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
Fix two issues observed during local CLI testing: - The fallback SSH command for Gerrit back-reference comments used -F /dev/null and IdentityAgent=none, which blocks agent-based SSH keys (e.g. Secretive, 1Password). Remove these restrictive options in local/CLI mode and preserve the system SSH_AUTH_SOCK so the user's SSH agent can authenticate - Downgrade the shallow clone merge-base failure from WARNING to DEBUG, since the tool handles this gracefully by deepening the repository automatically Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
Boolean options that default to True need the --no-* counterpart so users can disable them from the command line. Without the negation flag, Typer only shows the positive form in --help and provides no CLI mechanism to override the default. - Add --no-allow-duplicates (default: True) - Add --no-close-merged-prs (default: True) - Add --no-preserve-github-prs (default: True) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
|
Tested this pull request by using a development build of the CLI tool to process the FD.io changes that didn't get copied into the 'vpp' repository due to an earlier bug (that was fixed, but left several automation changes stuck in GitHub with no corresponding Gerrit change). |
483c03f to
70439c1
Compare
70439c1 to
93720b9
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address issues raised during Copilot code review and reviewer feedback: - CLI boolean env var overrides now check ctx.get_parameter_source() so that explicit --flag/--no-flag choices always take precedence over environment variables. The parse_bool_env workaround for GitHub Actions string "false" handling is preserved for non-CLI sources. Applied to all 12 boolean overrides in main() - Sort parse_commands() matches by comment_index so result ordering reflects the latest (winning) occurrence position, matching the documented oldest-to-newest comment order contract - Update module docstring to list both "create missing" and "create-missing" aliases, matching the command registry - Capture SSH_AUTH_SOCK before build_non_interactive_ssh_env() blanks it, so the Gerrit back-reference comment fallback in local/CLI mode can use agent-based keys (e.g. Secretive, 1Password) - Rename G2G_CREATE_MISSING env var to CREATE_MISSING for consistency with the other parameter env vars and the action.yaml input name Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
93720b9 to
dbc56c4
Compare
de84770
into
lfreleng-actions:main
Provide fallback mechanisms for when a previous GitHub2Gerrit run failed to create a corresponding Gerrit change. Previously, in this scenario, the tool would attempt to update an existing Gerrit change, fail to find one, and exit with an error.
Out fallback mechanism provides two invocation methods:
Adding this line as a comment on a pull request:
@github2gerrit create missing change
...will trigger the creation of a new change, and prevent a failed update call, which would otherwise cause the workflow run to error.