Class: Gitt::Repository
- Inherits:
-
Object
- Object
- Gitt::Repository
- 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
- #branch ⇒ Object
- #branch_default ⇒ Object
- #branch_name ⇒ Object
- #call ⇒ Object
- #commits ⇒ Object
- #config ⇒ Object
- #exist? ⇒ Boolean
- #get ⇒ Object
-
#initialize(shell: SHELL, commands: COMMANDS) ⇒ Repository
constructor
A new instance of Repository.
- #inspect ⇒ Object
- #log ⇒ Object
- #origin? ⇒ Boolean
- #set ⇒ Object
- #tag ⇒ Object
- #tag? ⇒ Boolean
- #tag_create ⇒ Object
- #tag_last ⇒ Object
- #tag_local? ⇒ Boolean
- #tag_remote? ⇒ Boolean
- #tag_show ⇒ Object
- #tagged? ⇒ Boolean
- #tags ⇒ Object
- #tags_push ⇒ Object
- #uncommitted ⇒ Object
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
#branch ⇒ Object
20 |
# File 'lib/gitt/repository.rb', line 20 def branch(...) = commands.fetch(__method__).call(...) |
#branch_default ⇒ Object
22 |
# File 'lib/gitt/repository.rb', line 22 def branch_default(...) = commands.fetch(:branch).default(...) |
#branch_name ⇒ Object
24 |
# File 'lib/gitt/repository.rb', line 24 def branch_name = commands.fetch(:branch).name |
#call ⇒ Object
26 |
# File 'lib/gitt/repository.rb', line 26 def call(...) = shell.call(...) |
#commits ⇒ Object
28 |
# File 'lib/gitt/repository.rb', line 28 def commits(...) = commands.fetch(:log).index(...) |
#config ⇒ Object
30 |
# File 'lib/gitt/repository.rb', line 30 def config(...) = commands.fetch(__method__).call(...) |
#exist? ⇒ Boolean
32 |
# File 'lib/gitt/repository.rb', line 32 def exist? = shell.call("rev-parse", "--git-dir").value_or(Core::EMPTY_STRING).chomp == ".git" |
#get ⇒ Object
34 |
# File 'lib/gitt/repository.rb', line 34 def get(...) = commands.fetch(:config).get(...) |
#inspect ⇒ Object
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 |
#log ⇒ Object
41 |
# File 'lib/gitt/repository.rb', line 41 def log(...) = commands.fetch(__method__).call(...) |
#origin? ⇒ Boolean
43 |
# File 'lib/gitt/repository.rb', line 43 def origin? = commands.fetch(:config).origin? |
#set ⇒ Object
45 |
# File 'lib/gitt/repository.rb', line 45 def set(...) = commands.fetch(:config).set(...) |
#tag ⇒ Object
47 |
# File 'lib/gitt/repository.rb', line 47 def tag(...) = commands.fetch(__method__).call(...) |
#tag? ⇒ Boolean
51 |
# File 'lib/gitt/repository.rb', line 51 def tag?(...) = commands.fetch(:tag).exist?(...) |
#tag_create ⇒ Object
53 |
# File 'lib/gitt/repository.rb', line 53 def tag_create(...) = commands.fetch(:tag).create(...) |
#tag_last ⇒ Object
55 |
# File 'lib/gitt/repository.rb', line 55 def tag_last = commands.fetch(:tag).last |
#tag_local? ⇒ Boolean
57 |
# File 'lib/gitt/repository.rb', line 57 def tag_local?(...) = commands.fetch(:tag).local?(...) |
#tag_remote? ⇒ Boolean
59 |
# File 'lib/gitt/repository.rb', line 59 def tag_remote?(...) = commands.fetch(:tag).remote?(...) |
#tag_show ⇒ Object
61 |
# File 'lib/gitt/repository.rb', line 61 def tag_show(...) = commands.fetch(:tag).show(...) |
#tagged? ⇒ Boolean
63 |
# File 'lib/gitt/repository.rb', line 63 def tagged? = commands.fetch(:tag).tagged? |
#tags ⇒ Object
49 |
# File 'lib/gitt/repository.rb', line 49 def (...) = commands.fetch(:tag).index(...) |
#tags_push ⇒ Object
65 |
# File 'lib/gitt/repository.rb', line 65 def = commands.fetch(:tag).push |
#uncommitted ⇒ Object
67 |
# File 'lib/gitt/repository.rb', line 67 def uncommitted(...) = commands.fetch(:log).uncommitted(...) |