Class: Abak::Flow::Branch
- Inherits:
-
Object
- Object
- Abak::Flow::Branch
- Defined in:
- lib/abak-flow/branch.rb
Constant Summary collapse
- FOLDER_HOTFIX =
"hotfix".freeze
- FOLDER_FEATURE =
"feature".freeze
- TASK_FORMAT =
'\w+\-\d{1,}'.freeze
- MAGICK_WORDS =
%w{close closes closed fix fixes fixed resolve resolves resolved}.freeze
- DEVELOPMENT =
"develop".freeze
- MASTER =
"master".freeze
- MAPPING =
{ FOLDER_HOTFIX => MASTER, FOLDER_FEATURE => DEVELOPMENT }.freeze
Instance Attribute Summary collapse
-
#folder ⇒ Object
readonly
Returns the value of attribute folder.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Instance Method Summary collapse
- #compare_link(branch) ⇒ Object
- #current? ⇒ Boolean
- #delete_on_local ⇒ Object
- #delete_on_remote ⇒ Object
- #develop? ⇒ Boolean
- #extract_base_name(options = Hash.new) ⇒ Object
-
#extract_body ⇒ Object
TODO : Сделать настраевыемым трекер и формат задачи.
- #extract_title ⇒ Object
- #feature? ⇒ Boolean
- #hotfix? ⇒ Boolean
-
#initialize(branch) ⇒ Branch
constructor
A new instance of Branch.
- #mappable? ⇒ Boolean
- #master? ⇒ Boolean
- #message ⇒ Object
- #name ⇒ Object
- #to_s ⇒ Object
- #tracker_task? ⇒ Boolean
- #update ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
Instance Attribute Details
#folder ⇒ Object (readonly)
Returns the value of attribute folder.
19 20 21 |
# File 'lib/abak-flow/branch.rb', line 19 def folder @folder end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
20 21 22 |
# File 'lib/abak-flow/branch.rb', line 20 def task @task end |
Instance Method Details
#compare_link(branch) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/abak-flow/branch.rb', line 44 def compare_link(branch) diff = "#{Manager.repository.upstream.owner}:#{branch}...#{@branch}" File.join [ Manager.github.web_endpoint, Manager.repository.origin.to_s, "compare", diff ] end |
#current? ⇒ Boolean
111 112 113 |
# File 'lib/abak-flow/branch.rb', line 111 def current? @branch.current end |
#delete_on_local ⇒ Object
83 84 85 |
# File 'lib/abak-flow/branch.rb', line 83 def delete_on_local @branch.delete end |
#delete_on_remote ⇒ Object
78 79 80 81 |
# File 'lib/abak-flow/branch.rb', line 78 def delete_on_remote origin = Manager.repository.origin.repo Manager.git.push(origin, ":#{@branch}") end |
#develop? ⇒ Boolean
87 88 89 |
# File 'lib/abak-flow/branch.rb', line 87 def develop? name == DEVELOPMENT end |
#extract_base_name(options = Hash.new) ⇒ Object
54 55 56 57 |
# File 'lib/abak-flow/branch.rb', line 54 def extract_base_name( = Hash.new) mappable? ? MAPPING[folder] : .fetch(:if_undef, name) end |
#extract_body ⇒ Object
TODO : Сделать настраевыемым трекер и формат задачи
65 66 67 68 69 70 71 |
# File 'lib/abak-flow/branch.rb', line 65 def extract_body return I18n.t("abak.flow.commands.publish.words.nothing") if .empty? && !tracker_task? [, task].flatten.compact.uniq .map { |x| "http://jira.railsc.ru/browse/#{x}" } * "\n" end |
#extract_title ⇒ Object
59 60 61 62 |
# File 'lib/abak-flow/branch.rb', line 59 def extract_title tracker_task? ? task : end |
#feature? ⇒ Boolean
99 100 101 |
# File 'lib/abak-flow/branch.rb', line 99 def feature? folder == FOLDER_FEATURE end |
#hotfix? ⇒ Boolean
95 96 97 |
# File 'lib/abak-flow/branch.rb', line 95 def hotfix? folder == FOLDER_HOTFIX end |
#mappable? ⇒ Boolean
107 108 109 |
# File 'lib/abak-flow/branch.rb', line 107 def mappable? hotfix? || feature? end |
#master? ⇒ Boolean
91 92 93 |
# File 'lib/abak-flow/branch.rb', line 91 def master? name == MASTER end |
#message ⇒ Object
33 34 35 36 37 38 |
# File 'lib/abak-flow/branch.rb', line 33 def content = @branch.gcommit..split("\n", 2).first return content if content.length < 72 content[0...72] << "..." end |
#name ⇒ Object
29 30 31 |
# File 'lib/abak-flow/branch.rb', line 29 def name @branch.full end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/abak-flow/branch.rb', line 40 def to_s @branch.to_s end |
#tracker_task? ⇒ Boolean
103 104 105 |
# File 'lib/abak-flow/branch.rb', line 103 def tracker_task? !(task =~ /^#{TASK_FORMAT}$/).nil? end |
#update ⇒ Object
73 74 75 76 |
# File 'lib/abak-flow/branch.rb', line 73 def update origin = Manager.repository.origin.repo Manager.git.push(origin, @branch) end |
#valid? ⇒ Boolean
115 116 117 |
# File 'lib/abak-flow/branch.rb', line 115 def valid? !@branch.name.strip.empty? end |