Class: Rosette::Core::Commands::CommitCommand

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

Overview

Inspects the given commit and extracts translatable phrases using the configured extractors. By design, CommitCommand (and the rest of Rosette) will not process merge commits. Generally, a snapshot of the repository will be necessary to find the commits where individual files were last changed (see the RepoSnapshotCommand or SnapshotFactory class to take snapshots).

Examples:

CommitCommand.new(configuration)
  .set_repo_name('my_repo')
  .set_ref('master')
  .execute
CommitCommand.new(configuration)
  .set_repo_name('my_repo')
  .set_commit_id('67f0e9a60dfe39430b346086f965e6c94a8ddd24')
  .execute

See Also:

Instance Attribute Summary

Attributes included from WithRef

#commit_str

Attributes included from WithRepoName

#repo_name

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 GitCommand

#valid?

Methods inherited from Command

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

Constructor Details

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

Instance Method Details

#executevoid

This method returns an undefined value.

Executes the command. Causes phrases to be extracted from the given git ref or commit id and written to the configured data store, triggering hooks in the process.


35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rosette/core/commands/git/commit_command.rb', line 35

def execute
  commit_processor.process_each_phrase(repo_name, commit_id) do |phrase|
    begin
      datastore.store_phrase(repo_name, phrase)
    rescue ActiveRecord::RecordNotUnique => e
      configuration.error_reporter.report_warning(e)
    end
  end

  trigger_hooks(:after)
end