Class: Git::Base
- Inherits:
-
Object
- Object
- Git::Base
- Defined in:
- lib/coral_core/util/git/base.rb
Overview
******************************************************************************* Base Git definition
Instance Method Summary collapse
-
#add(path = '.', opts = {}) ⇒ Object
—————————————————————————– Commit extensions.
-
#initialize(options = {}) ⇒ Base
constructor
—————————————————————————– Constructor / Destructor.
-
#pull(remote = 'origin', branch = 'master') ⇒ Object
—————————————————————————– Remote extensions.
Constructor Details
#initialize(options = {}) ⇒ Base
Constructor / Destructor
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/coral_core/util/git/base.rb', line 18 def initialize( = {}) if working_dir = [:working_directory] [:repository] ||= File.join(working_dir, '.git') if File.file?([:repository]) File.read([:repository]).each_line do |line| matches = line.match(/^\s*gitdir:\s*(.+)\s*/) if matches.length && matches[1] [:repository] = matches[1] break end end end if File.directory?([:repository]) [:index] ||= File.join([:repository], 'index') else raise GitDirectoryError.new("Git repository directory #{[:repository]} not found for #{working_dir}") end end if [:log] @logger = [:log] @logger.info("Starting Git") else @logger = nil end @working_directory = [:working_directory] ? Git::WorkingDirectory.new([:working_directory]) : nil @repository = [:repository] ? Git::Repository.new([:repository]) : nil @index = [:index] ? Git::Index.new([:index], false) : nil end |
Instance Method Details
#add(path = '.', opts = {}) ⇒ Object
Commit extensions
54 55 56 |
# File 'lib/coral_core/util/git/base.rb', line 54 def add(path = '.', opts = {}) self.lib.add(path, opts) end |
#pull(remote = 'origin', branch = 'master') ⇒ Object
Remote extensions
61 62 63 |
# File 'lib/coral_core/util/git/base.rb', line 61 def pull(remote = 'origin', branch = 'master') self.lib.pull(remote, branch) end |