Module: Rosette::Core::Commands::WithSnapshots

Included in:
DiffBaseCommand, ExportCommand, RepoSnapshotCommand, SnapshotCommand
Defined in:
lib/rosette/core/commands/git/with_snapshots.rb

Overview

Mixin capable of taking snapshots of git repositories. Meant to be mixed into the classes in Rosette::Core::Commands.

Examples:

class MyCommand < Rosette::Core::Commands::Command
  include WithSnapshots
end

cmd = MyCommand.new
snap = cmd.take_snapshot(repo_config, commit_id, paths)
snap  # => { 'path/to/file.rb' => '67f0e9a60dfe39430b346086f965e6c94a8ddd24', ... }

See Also:

Instance Method Summary collapse

Instance Method Details

#take_snapshot(repo_config, commit_id, paths = []) ⇒ Hash

Takes and returns a snapshot hash for the given repo and commit id. Limits the paths returned via the paths argument. If no paths are passed, #take_snapshot returns a snapshot containing all the paths in the repository.

Parameters:

  • repo_config (Rosette::Core::RepoConfig)

    The repository configuration to take the snapshot from.

  • commit_id (String)

    The git commit id to take the snapshot of.

  • paths (Array) (defaults to: [])

    The list of paths to consider when taking the snapshot. Only those paths included in this list will appear in the snapshot hash.

Returns:

  • (Hash)

    the snapshot hash (path to commit id pairs).


31
32
33
# File 'lib/rosette/core/commands/git/with_snapshots.rb', line 31

def take_snapshot(repo_config, commit_id, paths = [])
  __snapshot_factory__.take_snapshot(repo_config, commit_id, paths)
end