atlantis
atlantis copied to clipboard
fix: post workflow hook failures with delete source branch on merge
What
- Fixed post-workflow hooks failure after MR merge with deleted source branches: Modified PostWorkflowHooksCommandRunner to detect closed/merged MRs and use a different cloning strategy that doesn't attempt to fetch deleted source branches.
- Added comprehensive test coverage: Created test case specifically for the closed MR scenario to ensure the fix works correctly
Why
- Root cause: When
delete_source_branch_on_merge: trueis configured, Atlantis merges the MR and deletes the source branch, but post-workflow hooks still try to fetch the deleted branch using the merge strategy, causingfatal: couldn't find remote ref refs/heads/fooerrors - Business impact: This bug was preventing post-workflow hooks from executing after successful applies, breaking CI/CD pipelines and automated post-apply processes
- Solution approach: Detect when an MR is closed (merged) and use base branch cloning instead of merge strategy, avoiding the need to fetch deleted source branches
Tests
[x] I have tested my changes by creating a comprehensive test case in post_workflow_hooks_command_runner_test.go that verifies the closed MR scenario [x] I have validated that the fix handles both scenarios: existing working directories and new directory creation [x] I have confirmed that the existing functionality for open MRs remains unchanged
References
- Closing issue #4057
@jamengual
Hello :)
Should I change something regarding these check failures? Because there is usage of exec.Command all over the repo with variables coming from the client
Any update on this one?