Class: Rosette::Core::Commands::RepoSnapshotCommand

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

Overview

Takes a snapshot of a repository and returns the snapshot hash. Snapshots are simple hashes that map file paths to git commit ids. The commit ids indicate in which commit the corresponding file last changed.

Instance Attribute Summary collapse

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 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::Command

Instance Attribute Details

#pathsArray (readonly)

Returns the paths to consider when taking the snapshot. Any paths that do not exist in this array will not appear in the snapshot.

Returns:

  • (Array)

    the paths to consider when taking the snapshot. Any paths that do not exist in this array will not appear in the snapshot.


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rosette/core/commands/git/repo_snapshot_command.rb', line 14

class RepoSnapshotCommand < GitCommand
  attr_reader :paths

  include WithSnapshots
  include WithRepoName
  include WithRef

  # Set the paths that will be included in the snapshot.
  #
  # @param [Array] paths The paths to include in the snapshot.
  # @return [self]
  def set_paths(paths)
    @paths = paths
    self
  end

  # Take the snapshot.
  #
  # @return [Hash] the snapshot hash (file path to commit id pairs).
  def execute
    take_snapshot(get_repo(repo_name), commit_id, paths)
  end
end

Instance Method Details

#executeHash

Take the snapshot.

Returns:

  • (Hash)

    the snapshot hash (file path to commit id pairs).


33
34
35
# File 'lib/rosette/core/commands/git/repo_snapshot_command.rb', line 33

def execute
  take_snapshot(get_repo(repo_name), commit_id, paths)
end

#set_paths(paths) ⇒ self

Set the paths that will be included in the snapshot.

Parameters:

  • paths (Array)

    The paths to include in the snapshot.

Returns:

  • (self)

25
26
27
28
# File 'lib/rosette/core/commands/git/repo_snapshot_command.rb', line 25

def set_paths(paths)
  @paths = paths
  self
end