Class: Roger::Release::Scm::Git

Inherits:
Base
  • Object
show all
Defined in:
lib/roger/release/scm/git.rb

Overview

The GIT SCM implementation for Roger release

Instance Attribute Summary

Attributes inherited from Base

#config

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Git

Returns a new instance of Git.

Parameters:

  • config (Hash) (defaults to: {})

    a customizable set of options

Options Hash (config):

  • :ref (String)

    Ref to use for current tag

  • :path (String, Pathname)

    Path to working dir



25
26
27
28
# File 'lib/roger/release/scm/git.rb', line 25

def initialize(config = {})
  super(config)
  @config[:ref] ||= "HEAD"
end

Class Method Details

.find_git_dir(path) ⇒ Object

Find the .git dir in path and all it’s parents



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/roger/release/scm/git.rb', line 10

def self.find_git_dir(path)
  path = Pathname.new(path).realpath
  while path.parent != path && !(path + ".git").directory?
    path = path.parent
  end

  path += ".git"

  raise "Could not find suitable .git dir in #{path}" unless path.directory?

  path
end

Instance Method Details

#dateObject

Date will be Time.now if it can’t be determined from GIT repository



40
41
42
43
# File 'lib/roger/release/scm/git.rb', line 40

def date
  get_scm_data if @_date.nil?
  @_date
end

#previousObject



45
46
47
# File 'lib/roger/release/scm/git.rb', line 45

def previous
  self.class.new(@config.dup.update(ref: get_previous_tag_name))
end

#versionObject

Version is either:

  • the tagged version number (first “v” will be stripped) or

  • the return value of “git describe –tags HEAD”

  • the short SHA1 if there hasn’t been a previous tag



34
35
36
37
# File 'lib/roger/release/scm/git.rb', line 34

def version
  get_scm_data if @_version.nil?
  @_version
end