Skip to content

Commit

Permalink
Add --force to git fetch --tags command
Browse files Browse the repository at this point in the history
  • Loading branch information
kwboyd-shopify committed Jul 29, 2024
1 parent 4a79775 commit bb0423f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/shipit/stack_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def env
def fetch_commit(commit)
create_directories
if valid_git_repository?(@stack.git_path)
git('fetch', 'origin', '--quiet', '--tags', commit.sha, env: env, chdir: @stack.git_path)
git('fetch', 'origin', '--quiet', '--tags', '--force', commit.sha, env: env, chdir: @stack.git_path)
else
@stack.clear_git_cache!
git_clone(@stack.repo_git_url, @stack.git_path, branch: @stack.branch, env: env, chdir: @stack.deploys_path)
Expand All @@ -26,7 +26,7 @@ def fetch_commit(commit)
def fetch
create_directories
if valid_git_repository?(@stack.git_path)
git('fetch', 'origin', '--quiet', '--tags', @stack.branch, env: env, chdir: @stack.git_path)
git('fetch', 'origin', '--quiet', '--tags', '--force', @stack.branch, env: env, chdir: @stack.git_path)
else
@stack.clear_git_cache!
git_clone(@stack.repo_git_url, @stack.git_path, branch: @stack.branch, env: env, chdir: @stack.deploys_path)
Expand Down
4 changes: 2 additions & 2 deletions test/unit/deploy_commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def setup

command = @commands.fetch_commit(@deploy.until_commit)

assert_equal %W(git fetch origin --quiet --tags #{@deploy.until_commit.sha}), command.args
assert_equal %W(git fetch origin --quiet --tags --force #{@deploy.until_commit.sha}), command.args
end

test "#fetch_commit calls git fetch in git_path directory if repository cache already exist" do
Expand Down Expand Up @@ -121,7 +121,7 @@ def setup

command = @commands.fetch

assert_equal %w(git fetch origin --quiet --tags master), command.args
assert_equal %w(git fetch origin --quiet --tags --force master), command.args
end

test "#fetch calls git fetch in git_path directory if repository cache already exist" do
Expand Down

0 comments on commit bb0423f

Please sign in to comment.