fastlane/lib/fastlane/fast_file.rb in fastlane-2.222.0 vs fastlane/lib/fastlane/fast_file.rb in fastlane-2.223.0
- old
+ new
@@ -343,10 +343,14 @@
if is_eligible_for_caching
if version.nil?
# Update the repo if it's eligible for caching but the version isn't specified
UI.message("Fetching remote git branches and updating git repo...")
Helper.with_env_values('GIT_TERMINAL_PROMPT' => '0') do
- Actions.sh("cd #{clone_folder.shellescape} && git fetch --all --quiet && git checkout #{checkout_param.shellescape} #{checkout_path} && git reset --hard && git rebase")
+ command = "cd #{clone_folder.shellescape} && git fetch --all --quiet && git checkout #{checkout_param.shellescape} #{checkout_path} && git reset --hard"
+ # Check if checked out "branch" is actually a branch or a tag
+ current_branch = Actions.sh("cd #{clone_folder.shellescape} && git rev-parse --abbrev-ref HEAD")
+ command << " && git rebase" unless current_branch.strip.eql?("HEAD")
+ Actions.sh(command)
end
else
begin
# https://stackoverflow.com/a/1593574/865175
current_tag = Actions.sh("cd #{clone_folder.shellescape} && git describe --exact-match --tags HEAD").strip