fastlane/lib/fastlane/helper/git_helper.rb in fastlane-2.14.2 vs fastlane/lib/fastlane/helper/git_helper.rb in fastlane-2.15.0.beta.20170213032052

- old
+ new

@@ -1,34 +1,38 @@ module Fastlane module Actions GIT_MERGE_COMMIT_FILTERING_OPTIONS = [:include_merges, :exclude_merges, :only_include_merges].freeze - def self.git_log_between(pretty_format, from, to, merge_commit_filtering) - command = 'git log' - command << " --pretty=\"#{pretty_format}\" #{from.shellescape}...#{to.shellescape}" + def self.git_log_between(pretty_format, from, to, merge_commit_filtering, date_format = nil) + command = ['git log'] + command << "--pretty=\"#{pretty_format}\"" + command << "--date=\"#{date_format}\"" if date_format + command << "#{from.shellescape}...#{to.shellescape}" command << git_log_merge_commit_filtering_option(merge_commit_filtering) - Actions.sh(command, log: false).chomp + Actions.sh(command.compact.join(' '), log: false).chomp rescue nil end - def self.git_log_last_commits(pretty_format, commit_count, merge_commit_filtering) - command = 'git log' - command << " --pretty=\"#{pretty_format}\" -n #{commit_count}" + def self.git_log_last_commits(pretty_format, commit_count, merge_commit_filtering, date_format = nil) + command = ['git log'] + command << "--pretty=\"#{pretty_format}\"" + command << "--date=\"#{date_format}\"" if date_format + command << "-n #{commit_count}" command << git_log_merge_commit_filtering_option(merge_commit_filtering) - Actions.sh(command, log: false).chomp + Actions.sh(command.compact.join(' '), log: false).chomp rescue nil end def self.last_git_tag_name(match_lightweight = true, tag_match_pattern = nil) tag_pattern_param = tag_match_pattern ? "=#{tag_match_pattern.shellescape}" : '' command = ['git describe'] command << '--tags' if match_lightweight command << "`git rev-list --tags#{tag_pattern_param} --max-count=1`" - Actions.sh(command.join(' '), log: false).chomp + Actions.sh(command.compact.join(' '), log: false).chomp rescue nil end def self.last_git_commit_dict @@ -42,12 +46,15 @@ } end # Gets the last git commit information formatted into a String by the provided # pretty format String. See the git-log documentation for valid format placeholders - def self.last_git_commit_formatted_with(pretty_format) - Actions.sh("git log -1 --pretty=#{pretty_format}", log: false).chomp + def self.last_git_commit_formatted_with(pretty_format, date_format = nil) + command = ['git log -1'] + command << "--pretty=\"#{pretty_format}\"" + command << "--date=\"#{date_format}\"" if date_format + Actions.sh(command.compact.join(' '), log: false).chomp rescue nil end # @deprecated Use <tt>git_author_email</tt> instead @@ -91,14 +98,14 @@ private_class_method def self.git_log_merge_commit_filtering_option(merge_commit_filtering) case merge_commit_filtering when :exclude_merges - " --no-merges" + "--no-merges" when :only_include_merges - " --merges" - else - "" + "--merges" + when :include_merges + nil end end end end