module Git::Repository::Logging
Facade methods for querying commit history
Included by {Git::Repository}.
@api private
Constants
- FULL_LOG_COMMITS_ALLOWED_OPTS
-
Allowed option keys for {#full_log_commits}
@return [Array<Symbol>] the supported option keys
Public Instance Methods
Source
# File lib/git/repository/logging.rb, line 81 def full_log_commits(opts = {}) SharedPrivate.assert_valid_opts!(FULL_LOG_COMMITS_ALLOWED_OPTS, **opts) Private.validate_log_count_option!(opts) Private.validate_log_between_option!(opts) call_opts = Private.log_base_call_options(opts, skip: opts[:skip], merges: opts[:merges]) revision_range_args = Private.log_revision_range_args(opts) Private.run_log_command(@execution_context, revision_range_args, call_opts) end
Returns commits within the given revision range
@example Return commits from all refs
repo.full_log_commits(all: true).first['sha'] #=> "a1b2c3d4..."
@example Return commits between two revisions
repo.full_log_commits(between: ['v1.0.0', 'HEAD']).map { |c| c['sha'] } #=> ["d4e5f6...", "a1b2c3..."]
@param opts [Hash] options for the log query
@option opts [Integer, nil] :count (nil) maximum number of commits to return
@option opts [Boolean, nil] :all (nil) include commits reachable from any ref
@option opts [Boolean, nil] :cherry (nil) omit commits equivalent to
cherry-picked commits
@option opts [String] :since (nil) include commits newer than this date expression
@option opts [String] :until (nil) include commits older than this date expression
@option opts [String] :grep (nil) only include commits whose message matches
this pattern
@option opts [String] :author (nil) only include commits whose author matches
this pattern
@option opts [Array(String, String), nil] :between (nil) revision range as
two commit-ish values When both `:between` and `:object` are provided, `:between` takes precedence.
@option opts [String] :object (nil) single revision range expression for
`git log` Ignored when `:between` is provided.
@option opts [String, Pathname, Array<String, Pathname>, nil] :path_limiter (nil)
only include commits that impact files from the specified path(s)
@option opts [Integer, nil] :skip (nil) skip this many commits before output
@option opts [Boolean, nil] :merges (nil) include only merge commits
@return [Array<Hash>] the parsed raw log output for each commit
@raise [ArgumentError] if unsupported options are provided
@raise [ArgumentError] if ‘:count` is not an Integer
@raise [Git::FailedError] if git exits with a non-zero exit status
@see git-scm.com/docs/git-log git-log
Source
# File lib/git/repository/logging.rb, line 104 def log(count = 30) Git::Log.new(self, count) end
Returns a new {Git::Log} query builder scoped to this repository
@example Build a log query and execute it
results = repo.log(50).author('Alice').since('2 weeks ago').execute results.each { |commit| puts commit.sha }
@param count [Integer, Symbol, nil] the maximum number of commits to return,
or `:all` / `nil` to return all commits; passed directly to {Git::Log#initialize}
@return [Git::Log] a new log query builder
@see Git::Log