Class: Rosette::Core::Commands::StatusCommand

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

Overview

Computes the status of a git ref. Statuses contain the number of translations per locale as well as the state of the commit (pending, untranslated, or translated).

Examples:

cmd = StatusCommand.new(configuration)
  .set_repo_name('my_repo')
  .set_ref('master')

cmd.execute
# =>
# {
#   commit_id: "5756196042a3a307b43fd1a7092ecc6710eec42a",
#   status: "PENDING",
#   phrase_count: 100,
#   locales: [{
#     locale: 'fr-FR',
#     percent_translated: 0.5,
#     translated_count: 50
#   }, ... ]
# }

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

#executeHash

Computes the status for the configured repository and git ref. The status is computed by identifying the branch the ref belongs to, then examining and merging the statuses of all commits that belong to that branch.

Returns:

  • (Hash)

    a hash of status information for the ref:

    • commit_id: the commit id of the ref the status came from.

    • status: One of “FETCHED”, “EXTRACTED”, “PUSHED”, “FINALIZED”, or “NOT_FOUND”.

    • phrase_count: The number of phrases found in the commit.

    • locales: A hash of locale codes to locale statuses having these entries:

      • percent_translated: The percentage of phrase_count phrases that are currently translated in locale for this commit. In other words, translated_count / phrase_count.

      • translated_count: The number of translated phrases in locale for this commit.

See Also:


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/rosette/core/commands/git/status_command.rb', line 53

def execute
  repo_config = get_repo(repo_name)
  rev_walk = RevWalk.new(repo_config.repo.jgit_repo)
  all_refs = repo_config.repo.all_refs.values
  refs = repo_config.repo.refs_containing(
    commit_id, rev_walk, all_refs
  )

  commit_logs = commit_logs_for(
    refs.map(&:getName), repo_config, rev_walk, all_refs
  )

  status, phrase_count, locale_statuses = derive(
    refs, commit_logs, repo_config
  )

  rev_walk.dispose

  {
    status: status,
    commit_id: commit_id,
    phrase_count: phrase_count,
    locales: locale_statuses
  }
end