Class: BetweenMeals::Repo
- Inherits:
-
Object
- Object
- BetweenMeals::Repo
- Defined in:
- lib/between_meals/repo.rb,
lib/between_meals/repo/hg.rb,
lib/between_meals/repo/git.rb,
lib/between_meals/repo/svn.rb,
lib/between_meals/repo/hg/cmd.rb,
lib/between_meals/repo/git/cmd.rb,
lib/between_meals/repo/svn/cmd.rb
Overview
Local checkout wrapper
Defined Under Namespace
Instance Attribute Summary collapse
-
#bin ⇒ Object
Returns the value of attribute bin.
-
#repo_path ⇒ Object
readonly
Returns the value of attribute repo_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#changes(_start_ref, _end_ref) ⇒ Object
Return files changed between two revisions.
- #checkout ⇒ Object
- #create(_url) ⇒ Object
- #email ⇒ Object
- #exists? ⇒ Boolean
-
#files ⇒ Object
Return all files.
- #head ⇒ Object
- #head_msg ⇒ Object
- #head_msg= ⇒ Object
- #head_parents ⇒ Object
- #head_rev ⇒ Object
-
#initialize(repo_path, logger) ⇒ Repo
constructor
A new instance of Repo.
- #last_author ⇒ Object
- #last_msg ⇒ Object
- #last_msg= ⇒ Object
- #latest_revision ⇒ Object
- #name ⇒ Object
-
#repo_object ⇒ Object
Only interesting in the case of git where we have an underlying repo object courtesy of Rugged.
-
#setup ⇒ Object
This method must succeed in the case of no repo directory so that users can call ‘checkout`.
- #status ⇒ Object
- #update ⇒ Object
- #upstream?(_rev) ⇒ Boolean
- #valid_ref?(_rev) ⇒ Boolean
Constructor Details
#initialize(repo_path, logger) ⇒ Repo
Returns a new instance of Repo.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/between_meals/repo.rb', line 24 def initialize(repo_path, logger) @repo_path = repo_path @logger = logger @repo = nil @bin = nil setup rescue StandardError @logger.warn("Unable to read repo from #{File.(repo_path)}") exit(1) end |
Instance Attribute Details
#bin ⇒ Object
Returns the value of attribute bin.
22 23 24 |
# File 'lib/between_meals/repo.rb', line 22 def bin @bin end |
#repo_path ⇒ Object (readonly)
Returns the value of attribute repo_path.
22 23 24 |
# File 'lib/between_meals/repo.rb', line 22 def repo_path @repo_path end |
Class Method Details
.get(type, repo_path, logger) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/between_meals/repo.rb', line 35 def self.get(type, repo_path, logger) case type when 'auto' unless File.directory?(repo_path) logger.warn("#{repo_path} does not point to a repo") exit(1) end logger.info('Trying to detect repo type') require 'between_meals/repo/git' require 'between_meals/repo/hg' require 'between_meals/repo/svn' [ BetweenMeals::Repo::Git, BetweenMeals::Repo::Hg, BetweenMeals::Repo::Svn, ].each do |klass| begin r = klass.new(repo_path, logger) if r.exists? logger.info("Repo found to be #{klass.to_s.split('::').last}") return r end rescue StandardError logger.debug("Skipping #{klass}") end end logger.warn("Failed detecting repo type at #{repo_path}") exit(1) when 'svn' require 'between_meals/repo/svn' BetweenMeals::Repo::Svn.new(repo_path, logger) when 'git' require 'between_meals/repo/git' BetweenMeals::Repo::Git.new(repo_path, logger) when 'hg' require 'between_meals/repo/hg' BetweenMeals::Repo::Hg.new(repo_path, logger) else fail "Do not know repo type #{type}" end end |
Instance Method Details
#changes(_start_ref, _end_ref) ⇒ Object
Return files changed between two revisions
128 129 130 |
# File 'lib/between_meals/repo.rb', line 128 def changes(_start_ref, _end_ref) fail "#{__method__} not implemented" end |
#checkout ⇒ Object
145 146 147 |
# File 'lib/between_meals/repo.rb', line 145 def checkout fail "#{__method__} not implemented" end |
#create(_url) ⇒ Object
123 124 125 |
# File 'lib/between_meals/repo.rb', line 123 def create(_url) fail "#{__method__} not implemented" end |
#email ⇒ Object
165 166 167 |
# File 'lib/between_meals/repo.rb', line 165 def email fail "#{__method__} not implemented" end |
#exists? ⇒ Boolean
82 83 84 |
# File 'lib/between_meals/repo.rb', line 82 def exists? fail "#{__method__} not implemented" end |
#files ⇒ Object
Return all files
137 138 139 |
# File 'lib/between_meals/repo.rb', line 137 def files fail "#{__method__} not implemented" end |
#head ⇒ Object
141 142 143 |
# File 'lib/between_meals/repo.rb', line 141 def head fail "#{__method__} not implemented" end |
#head_msg ⇒ Object
107 108 109 |
# File 'lib/between_meals/repo.rb', line 107 def head_msg fail "#{__method__} not implemented" end |
#head_msg= ⇒ Object
111 112 113 |
# File 'lib/between_meals/repo.rb', line 111 def head_msg= fail "#{__method__} not implemented" end |
#head_parents ⇒ Object
115 116 117 |
# File 'lib/between_meals/repo.rb', line 115 def head_parents fail "#{__method__} not implemented" end |
#head_rev ⇒ Object
103 104 105 |
# File 'lib/between_meals/repo.rb', line 103 def head_rev fail "#{__method__} not implemented" end |
#last_author ⇒ Object
149 150 151 |
# File 'lib/between_meals/repo.rb', line 149 def fail "#{__method__} not implemented" end |
#last_msg ⇒ Object
153 154 155 |
# File 'lib/between_meals/repo.rb', line 153 def last_msg fail "#{__method__} not implemented" end |
#last_msg= ⇒ Object
157 158 159 |
# File 'lib/between_meals/repo.rb', line 157 def last_msg= fail "#{__method__} not implemented" end |
#latest_revision ⇒ Object
119 120 121 |
# File 'lib/between_meals/repo.rb', line 119 def latest_revision fail "#{__method__} not implemented" end |
#name ⇒ Object
161 162 163 |
# File 'lib/between_meals/repo.rb', line 161 def name fail "#{__method__} not implemented" end |
#repo_object ⇒ Object
Only interesting in the case of git where we have an underlying repo object courtesy of Rugged.
92 93 94 |
# File 'lib/between_meals/repo.rb', line 92 def repo_object fail "#{__method__} not implemented" end |
#setup ⇒ Object
This method must succeed in the case of no repo directory so that users can call ‘checkout`. Users may call `exists?` to find out if we have an underlying repo yet.
99 100 101 |
# File 'lib/between_meals/repo.rb', line 99 def setup fail "#{__method__} not implemented" end |
#status ⇒ Object
86 87 88 |
# File 'lib/between_meals/repo.rb', line 86 def status fail "#{__method__} not implemented" end |
#update ⇒ Object
132 133 134 |
# File 'lib/between_meals/repo.rb', line 132 def update fail "#{__method__} not implemented" end |
#upstream?(_rev) ⇒ Boolean
169 170 171 |
# File 'lib/between_meals/repo.rb', line 169 def upstream?(_rev) fail "#{__method__} not implemented" end |
#valid_ref?(_rev) ⇒ Boolean
173 174 175 |
# File 'lib/between_meals/repo.rb', line 173 def valid_ref?(_rev) fail "#{__method__} not implemented" end |