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



122
123
124
# File 'lib/between_meals/repo.rb', line 122

def changes(_start_ref, _end_ref)
  fail "#{__method__} not implemented"
end

#checkoutObject



139
140
141
# File 'lib/between_meals/repo.rb', line 139

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

#create(_url) ⇒ Object



117
118
119
# File 'lib/between_meals/repo.rb', line 117

def create(_url)
  fail "#{__method__} not implemented"
end

#emailObject



159
160
161
# File 'lib/between_meals/repo.rb', line 159

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



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

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

#headObject



135
136
137
# File 'lib/between_meals/repo.rb', line 135

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

#head_msgObject



101
102
103
# File 'lib/between_meals/repo.rb', line 101

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

#head_msg=Object



105
106
107
# File 'lib/between_meals/repo.rb', line 105

def head_msg=
  fail "#{__method__} not implemented"
end

#head_parentsObject



109
110
111
# File 'lib/between_meals/repo.rb', line 109

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

#head_revObject



97
98
99
# File 'lib/between_meals/repo.rb', line 97

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

#last_authorObject



143
144
145
# File 'lib/between_meals/repo.rb', line 143

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

#last_msgObject



147
148
149
# File 'lib/between_meals/repo.rb', line 147

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

#last_msg=Object



151
152
153
# File 'lib/between_meals/repo.rb', line 151

def last_msg=
  fail "#{__method__} not implemented"
end

#latest_revisionObject



113
114
115
# File 'lib/between_meals/repo.rb', line 113

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

#nameObject



155
156
157
# File 'lib/between_meals/repo.rb', line 155

def name
  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.



93
94
95
# File 'lib/between_meals/repo.rb', line 93

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



126
127
128
# File 'lib/between_meals/repo.rb', line 126

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

#upstream?(_rev) ⇒ Boolean

Returns:

  • (Boolean)


163
164
165
# File 'lib/between_meals/repo.rb', line 163

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

#valid_ref?(_rev) ⇒ Boolean

Returns:

  • (Boolean)


167
168
169
# File 'lib/between_meals/repo.rb', line 167

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