Module: Git::Repository::Inspecting
- Included in:
- Git::Repository
- Defined in:
- lib/git/repository/inspecting.rb
Overview
Facade methods for read-only repository inspection operations
These methods report on the contents and integrity of the repository.
Included by Git::Repository.
Instance Method Summary collapse
-
#describe(committish = nil, opts = {}) ⇒ String
Give a human-readable name to a commit based on the most recent reachable tag.
-
#fsck(*objects, **options) ⇒ Git::FsckResult
Verify the connectivity and validity of the objects in the database.
-
#show(objectish = nil, path = nil) ⇒ String
Show a single git object (a commit, tag, tree, or blob).
Instance Method Details
#describe(committish = nil, opts = {}) ⇒ String
Give a human-readable name to a commit based on the most recent reachable tag
Runs git describe to find the nearest tag reachable from committish and
formats a version string. When the tag points directly at the commit, only the
tag name is shown. Otherwise, the tag name is suffixed with the number of
additional commits and the abbreviated commit SHA (e.g. v1.0.0-3-gabcdef1).
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/git/repository/inspecting.rb', line 98 def describe(committish = nil, opts = {}) raise ArgumentError, "Invalid commit-ish object: '#{committish}'" if committish&.start_with?('-') opts = opts.dup if opts.key?(:'exact-match') opts[:exact_match] ||= opts[:'exact-match'] opts.delete(:'exact-match') end SharedPrivate.assert_valid_opts!(DESCRIBE_ALLOWED_OPTS, **opts) commit_ishes = Array(committish).compact Git::Commands::Describe.new(@execution_context).call(*commit_ishes, **opts).stdout end |
#fsck(*objects, **options) ⇒ Git::FsckResult
Verify the connectivity and validity of the objects in the database
Runs git fsck and returns the categorized objects it flags. Progress
output is always suppressed (--no-progress) so that stdout contains only
the machine-parsable findings.
245 246 247 248 249 |
# File 'lib/git/repository/inspecting.rb', line 245 def fsck(*objects, **) SharedPrivate.assert_valid_opts!(FSCK_ALLOWED_OPTS, **) result = Git::Commands::Fsck.new(@execution_context).call(*objects, **, no_progress: true) Git::Parsers::Fsck.parse(result.stdout) end |
#show(objectish = nil, path = nil) ⇒ String
Show a single git object (a commit, tag, tree, or blob)
139 140 141 142 |
# File 'lib/git/repository/inspecting.rb', line 139 def show(objectish = nil, path = nil) object = path ? "#{objectish || 'HEAD'}:#{path}" : objectish Git::Commands::Show.new(@execution_context).call(*[object].compact).stdout end |