Skip to content

Handle "would clobber existing tag" during --refresh#10

Open
vsc55 wants to merge 1 commit into
FreePBX:masterfrom
vsc55:bugfix/refresh-tag-clobber
Open

Handle "would clobber existing tag" during --refresh#10
vsc55 wants to merge 1 commit into
FreePBX:masterfrom
vsc55:bugfix/refresh-tag-clobber

Conversation

@vsc55

@vsc55 vsc55 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Running ./freepbx_git.php --refresh aborted on any repo whose remote had a moved or recreated tag. git fetch --tags fails in that case with would clobber existing tag and returns a non-zero status, which bubbled up as an uncaught, empty exception:

PHP Fatal error:  Uncaught Exception in /usr/src/devtools/libraries/Git.php:262
Stack trace:
#0 Git.php(277): GitRepo->run_command()
#1 Git.php(728): GitRepo->run()
#2 freepbx.php(139): GitRepo->fetch()
#3 freepbx_git.php(237): freepbx::refreshRepo()

The message was empty because the -q flag 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 --force to 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 $force is 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. --refreshhard forces tags automatically.
  • Documented the --force flag in the help output.

Behavior

Command On tag conflict
--refresh Asks once upfront: force always, or prompt per repo
--refresh --force Forces tag updates, no prompts
--refresh -y Same as --force
--refreshhard Forces tag updates automatically

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.
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