Class: Tol::Git

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGit

Returns a new instance of Git.



10
11
12
13
# File 'lib/tol/git.rb', line 10

def initialize
  size = HighLine::SystemExtensions.terminal_size
  self.terminal_columns = size[0]
end

Instance Attribute Details

#terminal_columnsObject

Returns the value of attribute terminal_columns.



8
9
10
# File 'lib/tol/git.rb', line 8

def terminal_columns
  @terminal_columns
end

Instance Method Details

#commitObject



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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/tol/git.rb', line 15

def commit
  puts Rainbow("Committing").foreground(:green)
  
  category = nil
  icon = nil
  choose do |menu|
    menu.prompt = "Category:"
    
    menu.choice "Bug" do 
      category = "bug"
      icon = ":heavy_exclamation_mark:"
    end

    menu.choice "Enhancement" do
      category = "enhancement"
      icon = ":lipstick:"
    end
    
    menu.choice "Feature" do
      category = "feature"
      icon = ":rocket:"
    end
    
    menu.choice "WIP" do
      category = "wip"
      icon = ":construction:"
    end
    
    menu.choice "Performance" do
      category = "performance"
      icon = ":racehorse:"
    end
    
    menu.choice "Housekeeping" do
      category = "housekeeping"
      icon = ":wrench:"
    end
    
    menu.choice "Cleanup (Code Deletion)" do
      category = "cleanup"
      icon = ":bathtub:"
    end
  end
  
  puts "Message: "
  message = STDIN.gets.gsub("\n", "")
  
  branch = `git rev-parse --abbrev-ref HEAD`.gsub("\n", "")
  
  message = "#{icon} #{message}"
  
  `git add -u .`
  `git add .`
  `git commit -m '#{message}'`
  `git push origin #{branch}`
end