fastlane/lib/fastlane/helper/git_helper.rb in fastlane-2.180.1 vs fastlane/lib/fastlane/helper/git_helper.rb in fastlane-2.181.0

- old
+ new

@@ -121,10 +121,18 @@ # Returns the current git branch, or "HEAD" if it's not checked out to any branch # Can be replaced using the environment variable `GIT_BRANCH` def self.git_branch env_name = SharedValues::GIT_BRANCH_ENV_VARS.find { |env_var| FastlaneCore::Env.truthy?(env_var) } - ENV.fetch(env_name.to_s) { Actions.sh("git rev-parse --abbrev-ref HEAD", log: false).chomp } + ENV.fetch(env_name.to_s) do + # Rescues if not a git repo or no commits in a git repo + begin + Actions.sh("git rev-parse --abbrev-ref HEAD", log: false).chomp + rescue => err + UI.verbose("Error getting git branch: #{err.message}") + nil + end + end end private_class_method def self.git_log_merge_commit_filtering_option(merge_commit_filtering) case merge_commit_filtering