Class: Rosette::Core::Commands::ShowCommand

Inherits:
DiffBaseCommand show all
Includes:
WithRef, WithRepoName
Defined in:
lib/rosette/core/commands/git/show_command.rb

Overview

Show the phrases that were added, removed, or modified directly by the given commit. Essentially this means a diff against the parent.

Examples:

cmd = ShowCommand.new(configuration)
  .set_repo_name('my_repo')
  .set_ref('my_branch')

cmd.execute
# {
#   added: [
#     { key: 'Foo', ... },
#   ],
#   removed: [
#     { key: 'I got deleted', ... }
#   ],
#   modified: [
#     { key: 'New value', old_key: 'Old value', ... }
#   ]
# }

Instance Attribute Summary

Attributes included from WithRef

#commit_str

Attributes included from WithRepoName

#repo_name

Attributes inherited from DiffBaseCommand

#strict

Attributes inherited from Command

#configuration

Instance Method Summary collapse

Methods included from WithRef

#commit_id, #set_commit_id, #set_ref

Methods included from WithRepoName

#set_repo_name

Methods inherited from DiffBaseCommand

#initialize, #set_strict

Methods included from WithSnapshots

#take_snapshot

Methods inherited from GitCommand

#valid?

Methods inherited from Command

#initialize, #messages, #valid?, validate, validators

Constructor Details

This class inherits a constructor from Rosette::Core::Commands::DiffBaseCommand

Instance Method Details

#executeHash

Computes the show (i.e. parent diff).

Returns:

  • (Hash)

    a hash of differences, grouped by added/removed/modified keys. Each value is an array of phrases. For added and removed phrases, the phrase hashes will contain normal phrase attributes. For changed phrases, the phrase hashes will contain normal phrase attributes plus a special old_key attribute that contains the previous key of the phrase. See the example above for a visual representation of the diff hash.


40
41
42
43
44
# File 'lib/rosette/core/commands/git/show_command.rb', line 40

def execute
  parent_commit_ids = build_parent_commit_list
  phrase_diff = diff_between(commit_id, parent_commit_ids)
  filter_phrase_diff(commit_id, parent_commit_ids, phrase_diff)
end