Skip to content

Commit

Permalink
Run 'git fetch' with '--force' if no revision given
Browse files Browse the repository at this point in the history
When we run 'git fetch' without a specific revision we
usually run it with '--all' which fetches tags (among
other things).

We now have movable tags in our plugin repositories
and when a tag is moved a 'git fetch' or 'checkout'
will produce a 'would clobber existing tag' error on
the command line, which warns the user that the tag
that has already been checked into the local clone
will be overwritten.

This commit fixes that error by running 'fetch' with
'--force' if we do not specify a revision.
  • Loading branch information
snim2 committed Mar 11, 2024
1 parent 3789ba5 commit bea0d2f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Git/Git.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function is_repo()

public function checkout($revision)
{
list($output, $return) = $this->run_command(['git', 'fetch', '-a', '&&', 'git', 'checkout', $revision]);
list($output, $return) = $this->run_command(['git', 'fetch', '-a', '--force', '&&', 'git', 'checkout', $revision]);

return $this->check_git_return('Checkout failed', $return, $output);
}
Expand Down Expand Up @@ -213,7 +213,7 @@ public function remote_revision_commit($revision)

public function fetch()
{
list($output, $return) = $this->run_command(['git', 'fetch', '-a']);
list($output, $return) = $this->run_command(['git', 'fetch', '-a', '--force']);

return $this->check_git_return('Checkout failed', $return, $output);
}
Expand Down

0 comments on commit bea0d2f

Please sign in to comment.