Class: YJCocoa::GitTagAdd

Inherits:
GitTag show all
Defined in:
lib/yjcocoa/git/git_tag_add.rb

Overview

Usage

Constant Summary

Constants inherited from Command

Command::DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from GitTag

#addTag, #deleteTags

Instance Method Summary collapse

Methods inherited from GitTag

#gitTagAdd, #gitTagDelete, #initialize, options, #validate!

Methods inherited from Git

#gitExist?

Methods inherited from Command

#askWithAnswers, options

Constructor Details

This class inherits a constructor from YJCocoa::GitTag

Instance Method Details

#current_branchObject



37
38
39
40
41
42
43
44
# File 'lib/yjcocoa/git/git_tag_add.rb', line 37

def current_branch
    list = (`git branch`).split("\n")
    for item in list
        if item =~ /\* /
            return item.gsub(/\* /, "")
        end
    end
end

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/yjcocoa/git/git_tag_add.rb', line 22

def run
    if File.exist?(".git")
        current_branch = self.current_branch
        tag = File.basename(Dir.pwd)
        tag << "-#{current_branch}" unless current_branch == "master"
        tag << "-#{Time.now.strftime('%Y%m%d%H%M')}"
        puts "YJCocoa build tag #{tag}".green
        system("yjcocoa git tag --add=#{tag}")
    else
        Dir.chdir("..") {
            self.run
        }
    end
end