Class: YJCocoa::GitTag

Inherits:
Git
  • Object
show all
Defined in:
lib/yjcocoa/git/git_tag.rb

Direct Known Subclasses

GitTagAdd, GitTagDelete

Constant Summary

Constants inherited from Command

Command::DEFAULT_OPTIONS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Git

#gitExist?

Methods inherited from Command

#askWithAnswers

Constructor Details

#initialize(argv) ⇒ GitTag

初始化



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

def initialize(argv)
    super
    self.addTag = argv.option('add')
    self.deleteTags = argv.option('delete')
    self.deleteTags = self.deleteTags.split(",").reject {|i| i.empty? } if self.deleteTags
end

Instance Attribute Details

#addTagObject

property



33
34
35
# File 'lib/yjcocoa/git/git_tag.rb', line 33

def addTag
  @addTag
end

#deleteTagsObject

Returns the value of attribute deleteTags.



34
35
36
# File 'lib/yjcocoa/git/git_tag.rb', line 34

def deleteTags
  @deleteTags
end

Class Method Details

.optionsObject



23
24
25
26
27
28
29
30
# File 'lib/yjcocoa/git/git_tag.rb', line 23

def self.options
    if self == YJCocoa::GitTag
        [['--add', '增加 tag, 多 tag 用 "," 分隔'],
        ['--delete', '删除 tag, 多 tag 用 "," 分隔']] + super
    else
        super
    end
end

Instance Method Details

#gitTagAddObject



61
62
63
64
# File 'lib/yjcocoa/git/git_tag.rb', line 61

def gitTagAdd
    puts "YJCocoa git add tag #{self.addTag}".green
    system("git push origin #{self.addTag}") if system("git tag #{self.addTag}")
end

#gitTagDeleteObject



66
67
68
69
70
71
# File 'lib/yjcocoa/git/git_tag.rb', line 66

def gitTagDelete
    puts "YJCocoa git delete tags #{self.deleteTags}".green
    self.deleteTags.each { |tag|
        system("git push origin :refs/tags/#{tag}") if system("git tag -d #{tag}")
    }
end

#runObject



53
54
55
56
57
58
59
# File 'lib/yjcocoa/git/git_tag.rb', line 53

def run
    if self.deleteTags && !self.deleteTags.empty?
        self.gitTagDelete
        puts
    end
    self.gitTagAdd if self.addTag
end

#validate!Object

businrss



45
46
47
48
49
50
51
# File 'lib/yjcocoa/git/git_tag.rb', line 45

def validate!
    super
    exit 0 unless self.gitExist?
    if self.class == YJCocoa::GitTag
        self.banner! unless self.addTag || self.deleteTags
    end
end