Module: GitCliPrompt::Tag

Includes:
CliPrompt, TR::CondUtils, TR::VerUtils
Defined in:
lib/tag.rb

Defined Under Namespace

Classes: TagError

Instance Method Summary collapse

Methods included from CliPrompt

#method_missing

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class GitCliPrompt::CliPrompt

Instance Method Details

#tag(root, version, &block) ⇒ Object

Raises:



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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/tag.rb', line 11

def tag(root, version, &block)

  raise TagError, "Workspace root cannot be empty" if is_empty?(root)
  raise TagError, "Version name cannot be empty" if is_empty?(version)

  ws = Gvcs::Workspace.new(root)

  if ws.is_workspace?
    vers = possible_versions(currentVersion)

    vers << "Custom"
    vers << [
      "Not feeling to tag now" \
      ,"Maybe not now..." \
      ,"Nah, forget it..." \
    ].sample

    sel = pmt.select("Please select one of the options below:") do |menu|
      vers.each do |v|
        menu.choice v
      end
    end

    case sel
    when "Custom"
      sel = pmt.ask("Please provide custom version no:", required: true) 
    when vers[-1]
      raise UserChangedMind
    end

    defTagMsg = block.call(:default_tag_message) if block
    if is_empty?(defTagMsg)
      defTagMsg = "Automated tagging of source code of release version #{sel}" 
    end

    msg = pmt.ask("Message for this tag : ", default: defTagMsg)

    ws.create_tag(sel, msg)

  else
    raise TagError, "Given path '#{root}' is not a workspace"
  end


end