Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --force to git fetch --tags command #1357

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading