diff --git a/lib/OpenQA/Task/Git/Clone.pm b/lib/OpenQA/Task/Git/Clone.pm index 29d995aea515..8dca6af0dac7 100644 --- a/lib/OpenQA/Task/Git/Clone.pm +++ b/lib/OpenQA/Task/Git/Clone.pm @@ -112,15 +112,8 @@ sub _git_clone ($job, $ctx, $path, $url) { } my $current_branch = _get_current_branch($path); - if ($requested_branch eq $current_branch) { - # updating default branch (including checkout) - _git_fetch($path, $requested_branch); - _git_reset_hard($path, $requested_branch); - } - else { - # updating local branch to latest remote branch version - _git_fetch($path, "$requested_branch:$requested_branch"); - } + _git_fetch($path, $requested_branch); + _git_reset_hard($path, $requested_branch) if ($requested_branch eq $current_branch); } 1; diff --git a/t/14-grutasks.t b/t/14-grutasks.t index 92c060d28205..fa19d46a1009 100644 --- a/t/14-grutasks.t +++ b/t/14-grutasks.t @@ -671,7 +671,6 @@ subtest 'git clone' => sub { is $res->{result}, 'Job successfully executed', 'minion job result indicates success'; like $mocked_git_calls[3], qr'git -C /etc/ fetch origin master', 'fetch origin master for /etc/'; like $mocked_git_calls[4], qr'reset --hard origin/master', 'reset origin/master for /etc/'; - like $mocked_git_calls[8], qr'git -C /root/ fetch origin foobranch:foobranch', 'fetch non-default branch'; like $mocked_git_calls[10], qr'git clone http://localhost/bar.git /this_directory_does_not_exist/', 'clone to /this_directory_does_not_exist/';