Class: BetweenMeals::Repo

Inherits:
Object
  • Object
show all
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

Direct Known Subclasses

Git, Hg, Svn

Defined Under Namespace

Classes: Git, Hg, Svn

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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.expand_path(repo_path)}")
  exit(1)
end

Instance Attribute Details

#binObject

Returns the value of attribute bin.



22
23
24
# File 'lib/between_meals/repo.rb', line 22

def bin
  @bin
end

#repo_pathObject (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

#checkoutObject



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

#emailObject



165
166
167
# File 'lib/between_meals/repo.rb', line 165

def email
  fail "#{__method__} not implemented"
end

#exists?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/between_meals/repo.rb', line 82

def exists?
  fail "#{__method__} not implemented"
end

#filesObject

Return all files



137
138
139
# File 'lib/between_meals/repo.rb', line 137

def files
  fail "#{__method__} not implemented"
end

#headObject



141
142
143
# File 'lib/between_meals/repo.rb', line 141

def head
  fail "#{__method__} not implemented"
end

#head_msgObject



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_parentsObject



115
116
117
# File 'lib/between_meals/repo.rb', line 115

def head_parents
  fail "#{__method__} not implemented"
end

#head_revObject



103
104
105
# File 'lib/between_meals/repo.rb', line 103

def head_rev
  fail "#{__method__} not implemented"
end

#last_authorObject



149
150
151
# File 'lib/between_meals/repo.rb', line 149

def last_author
  fail "#{__method__} not implemented"
end

#last_msgObject



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_revisionObject



119
120
121
# File 'lib/between_meals/repo.rb', line 119

def latest_revision
  fail "#{__method__} not implemented"
end

#nameObject



161
162
163
# File 'lib/between_meals/repo.rb', line 161

def name
  fail "#{__method__} not implemented"
end

#repo_objectObject

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

#setupObject

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

#statusObject



86
87
88
# File 'lib/between_meals/repo.rb', line 86

def status
  fail "#{__method__} not implemented"
end

#updateObject



132
133
134
# File 'lib/between_meals/repo.rb', line 132

def update
  fail "#{__method__} not implemented"
end

#upstream?(_rev) ⇒ Boolean

Returns:

  • (Boolean)


169
170
171
# File 'lib/between_meals/repo.rb', line 169

def upstream?(_rev)
  fail "#{__method__} not implemented"
end

#valid_ref?(_rev) ⇒ Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/between_meals/repo.rb', line 173

def valid_ref?(_rev)
  fail "#{__method__} not implemented"
end