Class: Pkgr::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/pkgr/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Git

Returns a new instance of Git.



7
8
9
# File 'lib/pkgr/git.rb', line 7

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/pkgr/git.rb', line 5

def path
  @path
end

Instance Method Details

#latest_tagObject



11
12
13
14
15
16
17
18
19
# File 'lib/pkgr/git.rb', line 11

def latest_tag
  return nil unless valid?
  Dir.chdir(path) do
    git_describe = Mixlib::ShellOut.new("git describe --tags --abbrev=0")
    git_describe.logger = Pkgr.logger
    git_describe.run_command
    git_describe.stdout.chomp
  end
end

#valid?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/pkgr/git.rb', line 21

def valid?
  File.file?(File.join(path, ".git", "index"))
end