Class: Texico::CLI::Command::Release

Inherits:
Build
  • Object
show all
Defined in:
lib/texico/cli/command/release.rb

Constant Summary collapse

GIT_DIR =
File.expand_path('.git').freeze

Constants inherited from Build

Build::SHADOW_BUILD_DIR

Instance Attribute Summary

Attributes inherited from Base

#opts, #prompt

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Build

#build

Methods inherited from Base

inherited, #initialize, #load_config, match, priority, select

Constructor Details

This class inherits a constructor from Texico::CLI::Command::Base

Class Method Details

.match?(command) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/texico/cli/command/release.rb', line 49

def match?(command)
  command == 'release'
end

Instance Method Details

#runObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/texico/cli/command/release.rb', line 7

def run
  unless File.exist? GIT_DIR
    prompt.error "#{ICON} You don't seem to be using git."
    exit
  end
  
  unless label
    tags = Git.list_tags('.')
    num_tags = tags.length
    count = case num_tags
            when 0 then 'no releases'
            when 1 then 'one release'
            else "#{num_tags} releases"
            end
    prompt.say "#{ICON} This project currently has #{count}\n",
               color: :bold

    if num_tags > 0
      prompt.say tags.map { |t| "* #{t}" }.join("\n")
    end

    exit
  end
  
  success = super # Build the project
  
  unless success
    prompt.error "#{ICON} I will only tag the release when it builds " \
                 "without errors."
    exit
  end
  
  Git.tag '.', label, "Releasing #{label}"
end