Handle "would clobber existing tag" during --refresh#10
Open
vsc55 wants to merge 1 commit into
Open
Conversation
A plain `git fetch --tags` aborts when a remote tag has been moved or
recreated ("would clobber existing tag"), which made `freepbx_git.php
--refresh` die with an uncaught, empty exception (the `-q` flag hid the
stderr that would have explained it).
Recover from this gracefully and let the user decide whether to force:
- Git::fetch() takes an optional $force flag that adds --force to the
tag fetch.
- freepbx::refreshRepo() wraps the fetch in a try/catch. On failure it
forces the tag update when $force is set, otherwise prompts per repo;
declining just reports the error and continues with the next module
instead of aborting the whole run.
- freepbx_git.php --refresh resolves the force mode from --force (or -y),
or asks once upfront whether to force automatically or be prompted on
each conflict. --refreshhard forces tags automatically.
- Document the --force flag in the help output.
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.
Problem
Running
./freepbx_git.php --refreshaborted on any repo whose remote had a moved or recreated tag.git fetch --tagsfails in that case withwould clobber existing tagand returns a non-zero status, which bubbled up as an uncaught, empty exception:The message was empty because the
-qflag suppressed the stderr that would have explained the failure, and a single bad repo aborted the entire refresh run.Changes
Git::fetch($force = false)— optional flag that adds--forceto the tag fetch. The library stays non-interactive.freepbx::refreshRepo(..., $force = false)— wraps the fetch in a try/catch. On failure it forces the tag update when$forceis set, otherwise prompts for that repo. Declining now reports a clear error and continues with the next module instead of crashing the whole run.freepbx_git.php --refresh— resolves the force mode from--force(or-y), or asks once upfront whether to force automatically or be prompted on each conflict.--refreshhardforces tags automatically.--forceflag in the help output.Behavior
--refresh--refresh --force--refresh -y--force--refreshhard