Class: Ed::Repository
- Inherits:
-
Object
- Object
- Ed::Repository
- Defined in:
- lib/ed/repository.rb
Overview
The Repository class provides a interface to talk to a Git repository.
It does not make a copy of the repository but works off the path it is
given.
The RepositoryCopy class provides the same interface as this class but
it creates a working copy of the repository to allow for parallel access.
The default behavior is to use RepositoryCopy when talking to a
repository but if you would like to disable copying you can use the
Config#copy_repository= config option. You should be aware of its
implications, though.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#path ⇒ String
readonly
The path to the repository on local disk.
Class Method Summary collapse
-
.local?(path) ⇒ Boolean
Returns true if the path is considered to be local.
-
.ls_remote(*args) {|sha, ref| ... } ⇒ Enumerator
Returns a Enumerator if no block is given.
-
.remote?(path) ⇒ Boolean
Returns true if the path is considered to be remote.
Instance Method Summary collapse
- #checkout(*args) ⇒ void
-
#initialize(path) ⇒ Ed::Repository
constructor
Returns a instance of Repository.
Constructor Details
#initialize(path) ⇒ Ed::Repository
Returns a instance of Ed::Repository.
81 82 83 |
# File 'lib/ed/repository.rb', line 81 def initialize path @path = path end |
Instance Attribute Details
#path ⇒ String (readonly)
Returns The path to the repository on local disk.
72 73 74 |
# File 'lib/ed/repository.rb', line 72 def path @path end |
Class Method Details
.local?(path) ⇒ Boolean
Returns true if the path is considered to be local.
35 36 37 |
# File 'lib/ed/repository.rb', line 35 def self.local? path URI.parse(path).scheme == "file" || !to_s.include?(':') end |
.ls_remote(*args) {|sha, ref| ... } ⇒ Enumerator
Returns a Enumerator if no block is given.
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ed/repository.rb', line 55 def self.ls_remote *args unless block_given? return enum_for(:ls_remote, *args) end output = ShellCommand.run!("git ls-remote #{args.join(' ')}").stdout output.each_line do |line| sha, ref = line.split(/\s+/, 2) yield sha, ref.chomp end end |
.remote?(path) ⇒ Boolean
Returns true if the path is considered to be remote.
24 25 26 |
# File 'lib/ed/repository.rb', line 24 def self.remote? path !local?(path) end |
Instance Method Details
#checkout(*args) ⇒ void
This method returns an undefined value.
91 92 93 |
# File 'lib/ed/repository.rb', line 91 def checkout *args git "checkout", *args end |