Class: Snippy::Git

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

Instance Method Summary collapse

Instance Method Details

#retagObject

Raises:

  • (Thor::Error)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/snippy/git.rb', line 9

def retag
  raise Thor::Error, "Not a git repository!" unless Dir.exists?(".git")
  g = ::Git.open(".")
  tags = g.tags
  raise Thor::Error, "No tag found!" if tags.empty?
  tag = tags.pop.name
  puts "Deleting tag: #{tag}"
  system "git tag -d #{tag}"
  puts "Creating tag: #{tag}"
  g.add_tag(tag)
  if options[:push]
    raise Thor::Error, "No remote!" if g.branches.remote.empty?
    puts "Pushing files"
    g.push
  end
end