Class: Bugwatch::Repo
- Inherits:
-
Object
- Object
- Bugwatch::Repo
- Defined in:
- lib/bugwatch/repo.rb
Constant Summary collapse
- REPO_PATH =
'repos'
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #analyze(caching_strategy, *analyzers) ⇒ Object
- #analyze!(caching_strategy, analyzers, begin_sha = nil) ⇒ Object
- #clone! ⇒ Object
- #commit(sha) ⇒ Object
- #commit_shas(begin_sha = nil) ⇒ Object
- #commits(begin_sha = nil) ⇒ Object
- #discover! ⇒ Object
- #exists? ⇒ Boolean
- #grit ⇒ Object
- #head ⇒ Object
- #import(caching_strategy, begin_sha = nil) ⇒ Object
-
#initialize(name, url) ⇒ Repo
constructor
A new instance of Repo.
- #tags ⇒ Object
- #tree ⇒ Object
- #update! ⇒ Object
Constructor Details
#initialize(name, url) ⇒ Repo
Returns a new instance of Repo.
43 44 45 46 |
# File 'lib/bugwatch/repo.rb', line 43 def initialize(name, url) @name = name @url = url end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
37 38 39 |
# File 'lib/bugwatch/repo.rb', line 37 def name @name end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
37 38 39 |
# File 'lib/bugwatch/repo.rb', line 37 def url @url end |
Class Method Details
.discover(name, url) ⇒ Object
39 40 41 |
# File 'lib/bugwatch/repo.rb', line 39 def self.discover(name, url) new(name, url).tap {|repo| repo.discover! } end |
Instance Method Details
#analyze(caching_strategy, *analyzers) ⇒ Object
77 78 79 |
# File 'lib/bugwatch/repo.rb', line 77 def analyze(caching_strategy, *analyzers) Analysis.new(self, caching_strategy).analyze(*analyzers) end |
#analyze!(caching_strategy, analyzers, begin_sha = nil) ⇒ Object
68 69 70 71 |
# File 'lib/bugwatch/repo.rb', line 68 def analyze!(caching_strategy, analyzers, begin_sha=nil) import(caching_strategy, begin_sha) analyze(caching_strategy, *analyzers) end |
#clone! ⇒ Object
56 57 58 |
# File 'lib/bugwatch/repo.rb', line 56 def clone! Kernel.system("cd #{REPO_PATH}; git clone #{url} #{name}") end |
#commit(sha) ⇒ Object
91 92 93 94 |
# File 'lib/bugwatch/repo.rb', line 91 def commit(sha) grit_commit = grit.commit(sha) Commit.from_grit(grit_commit) if grit_commit end |
#commit_shas(begin_sha = nil) ⇒ Object
96 97 98 |
# File 'lib/bugwatch/repo.rb', line 96 def commit_shas(begin_sha=nil) rugged_repo.walk(sha_or_head(begin_sha)).map(&:oid) end |
#commits(begin_sha = nil) ⇒ Object
85 86 87 88 89 |
# File 'lib/bugwatch/repo.rb', line 85 def commits(begin_sha=nil) rugged_repo.walk(sha_or_head(begin_sha)).map do |rugged_commit| self.commit(rugged_commit.oid) end end |
#discover! ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/bugwatch/repo.rb', line 48 def discover! if exists? update! else clone! end end |
#exists? ⇒ Boolean
64 65 66 |
# File 'lib/bugwatch/repo.rb', line 64 def exists? File.exists?(path_to_repo) end |
#grit ⇒ Object
104 105 106 |
# File 'lib/bugwatch/repo.rb', line 104 def grit @grit ||= Grit::Repo.new(path_to_repo) end |
#head ⇒ Object
81 82 83 |
# File 'lib/bugwatch/repo.rb', line 81 def head rugged_repo.head.target end |
#import(caching_strategy, begin_sha = nil) ⇒ Object
73 74 75 |
# File 'lib/bugwatch/repo.rb', line 73 def import(caching_strategy, begin_sha=nil) Import.new(self, caching_strategy).import(sha_or_head(begin_sha)) end |
#tags ⇒ Object
108 109 110 111 112 |
# File 'lib/bugwatch/repo.rb', line 108 def .map do |tag| Tag.new(tag) end end |
#update! ⇒ Object
60 61 62 |
# File 'lib/bugwatch/repo.rb', line 60 def update! Kernel.system("cd #{path_to_repo}; git fetch origin master; git reset --hard origin/master; git fetch --tags") end |