Class: Yolo::Tools::Git
- Inherits:
-
Object
- Object
- Yolo::Tools::Git
- Defined in:
- lib/yolo/tools/git.rb
Overview
Runs git commands
Instance Attribute Summary collapse
-
#project_name ⇒ Object
A unique name used to identify the project and its history.
Instance Method Summary collapse
-
#commit ⇒ String
The latest commit hash.
-
#current_branch ⇒ String
Finds the current branch using some regex and git branch.
-
#has_new_commit(name) ⇒ BOOL
Checks against the yaml history to see if a new commit is present to build.
-
#has_new_tag(name) ⇒ BOOL
Checks against the yaml history to see if a new tag is present to build.
-
#initialize ⇒ Git
constructor
Creates the class with default variables, sets the path to the history yml file and loads it.
-
#tag ⇒ String
The latest git tag.
Constructor Details
#initialize ⇒ Git
Creates the class with default variables, sets the path to the history yml file and loads it.
19 20 21 22 23 |
# File 'lib/yolo/tools/git.rb', line 19 def initialize @yaml_path = File.dirname(__FILE__) + "/../history/history.yml" @yaml = YAML::load_file @yaml_path @formatter = Yolo::Formatters::ProgressFormatter.new end |
Instance Attribute Details
#project_name ⇒ Object
A unique name used to identify the project and its history
13 14 15 |
# File 'lib/yolo/tools/git.rb', line 13 def project_name @project_name end |
Instance Method Details
#commit ⇒ String
The latest commit hash
78 79 80 |
# File 'lib/yolo/tools/git.rb', line 78 def commit @commit end |
#current_branch ⇒ String
Finds the current branch using some regex and git branch
86 87 88 89 90 91 92 93 94 |
# File 'lib/yolo/tools/git.rb', line 86 def current_branch branch = `git branch` branchs = branch.split("\n") current_branch = "" branchs.each do |b| current_branch = b if b.count("*") == 1 end current_branch.gsub("* ", "") end |
#has_new_commit(name) ⇒ BOOL
Checks against the yaml history to see if a new commit is present to build
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/yolo/tools/git.rb', line 30 def has_new_commit(name) set_project_name(name) if yaml_commit == latest_commit @formatter.no_new_commit false else @formatter.new_commit(latest_commit) update_commit(latest_commit) true end end |
#has_new_tag(name) ⇒ BOOL
Checks against the yaml history to see if a new tag is present to build
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/yolo/tools/git.rb', line 47 def has_new_tag(name) new_tag = false set_project_name(name) if latest_tag if yaml_tag != latest_tag or has_new_commit(name) @formatter.new_tag(latest_tag) update_tag(latest_tag) new_tag = true end end unless new_tag @formatter.no_new_tag end new_tag end |
#tag ⇒ String
The latest git tag
70 71 72 |
# File 'lib/yolo/tools/git.rb', line 70 def tag @tag end |