Class: Gitt::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/gitt/repository.rb

Overview

Primary object/wrapper for processing all Git related commands.

Constant Summary collapse

COMMANDS =
{
  branch: Commands::Branch,
  config: Commands::Config,
  log: Commands::Log,
  tag: Commands::Tag
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(shell: SHELL, commands: COMMANDS) ⇒ Repository

Returns a new instance of Repository.



15
16
17
18
# File 'lib/gitt/repository.rb', line 15

def initialize shell: SHELL, commands: COMMANDS
  @shell = shell
  @commands = commands.transform_values { |command| command.new shell: }
end

Instance Method Details

#branchObject



20
# File 'lib/gitt/repository.rb', line 20

def branch(...) = commands.fetch(__method__).call(...)

#branch_defaultObject



22
# File 'lib/gitt/repository.rb', line 22

def branch_default(...) = commands.fetch(:branch).default(...)

#branch_nameObject



24
# File 'lib/gitt/repository.rb', line 24

def branch_name = commands.fetch(:branch).name

#callObject



26
# File 'lib/gitt/repository.rb', line 26

def call(...) = shell.call(...)

#commitsObject



28
# File 'lib/gitt/repository.rb', line 28

def commits(...) = commands.fetch(:log).index(...)

#configObject



30
# File 'lib/gitt/repository.rb', line 30

def config(...) = commands.fetch(__method__).call(...)

#exist?Boolean

Returns:

  • (Boolean)


32
# File 'lib/gitt/repository.rb', line 32

def exist? = shell.call("rev-parse", "--git-dir").value_or(Core::EMPTY_STRING).chomp == ".git"

#getObject



34
# File 'lib/gitt/repository.rb', line 34

def get(...) = commands.fetch(:config).get(...)

#inspectObject



36
37
38
39
# File 'lib/gitt/repository.rb', line 36

def inspect
  "#<#{self.class}:#{object_id} @shell=#{shell.inspect} " \
  "@commands=#{commands.values.map(&:class).inspect}>"
end

#logObject



41
# File 'lib/gitt/repository.rb', line 41

def log(...) = commands.fetch(__method__).call(...)

#origin?Boolean

Returns:

  • (Boolean)


43
# File 'lib/gitt/repository.rb', line 43

def origin? = commands.fetch(:config).origin?

#setObject



45
# File 'lib/gitt/repository.rb', line 45

def set(...) = commands.fetch(:config).set(...)

#tagObject



47
# File 'lib/gitt/repository.rb', line 47

def tag(...) = commands.fetch(__method__).call(...)

#tag?Boolean

Returns:

  • (Boolean)


51
# File 'lib/gitt/repository.rb', line 51

def tag?(...) = commands.fetch(:tag).exist?(...)

#tag_createObject



53
# File 'lib/gitt/repository.rb', line 53

def tag_create(...) = commands.fetch(:tag).create(...)

#tag_lastObject



55
# File 'lib/gitt/repository.rb', line 55

def tag_last = commands.fetch(:tag).last

#tag_local?Boolean

Returns:

  • (Boolean)


57
# File 'lib/gitt/repository.rb', line 57

def tag_local?(...) = commands.fetch(:tag).local?(...)

#tag_remote?Boolean

Returns:

  • (Boolean)


59
# File 'lib/gitt/repository.rb', line 59

def tag_remote?(...) = commands.fetch(:tag).remote?(...)

#tag_showObject



61
# File 'lib/gitt/repository.rb', line 61

def tag_show(...) = commands.fetch(:tag).show(...)

#tagged?Boolean

Returns:

  • (Boolean)


63
# File 'lib/gitt/repository.rb', line 63

def tagged? = commands.fetch(:tag).tagged?

#tagsObject



49
# File 'lib/gitt/repository.rb', line 49

def tags(...) = commands.fetch(:tag).index(...)

#tags_pushObject



65
# File 'lib/gitt/repository.rb', line 65

def tags_push = commands.fetch(:tag).push

#uncommittedObject



67
# File 'lib/gitt/repository.rb', line 67

def uncommitted(...) = commands.fetch(:log).uncommitted(...)