Class: GTA::Stage
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#final ⇒ Object
readonly
Returns the value of attribute final.
-
#hotfixable ⇒ Object
readonly
Returns the value of attribute hotfixable.
-
#manager ⇒ Object
readonly
Returns the value of attribute manager.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#restorable ⇒ Object
readonly
Returns the value of attribute restorable.
-
#source_name ⇒ Object
readonly
Returns the value of attribute source_name.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add_remote ⇒ Object
- #checkout ⇒ Object
- #checkout! ⇒ Object
- #checkout_command ⇒ Object
- #delete_existing_branch ⇒ Object
- #existing_branch? ⇒ Boolean
- #fetch ⇒ Object
- #fetch! ⇒ Object
- #fetch_command ⇒ Object
- #final? ⇒ Boolean
- #force_push(s = source) ⇒ Object
- #hotfixable? ⇒ Boolean
-
#initialize(name, manager, opts) ⇒ Stage
constructor
A new instance of Stage.
- #push(s = source, forced = nil) ⇒ Object
- #push_command(source_ref, forced = nil) ⇒ Object
- #restorable? ⇒ Boolean
- #source ⇒ Object
-
#source_from(s) ⇒ Object
———–.
- #source_ref ⇒ Object
- #stages ⇒ Object
Methods included from Sh
Constructor Details
#initialize(name, manager, opts) ⇒ Stage
Returns a new instance of Stage.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/gta/stage.rb', line 8 def initialize(name, manager, opts) @name = name @manager = manager @repository = opts['repository'] @source_name = opts['source'] @branch = opts['branch'] || 'master' @tag = opts['tag'] @final = opts['final'] @hotfixable = opts['hotfixable'] @restorable = opts['restorable'] end |
Instance Attribute Details
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
5 6 7 |
# File 'lib/gta/stage.rb', line 5 def branch @branch end |
#final ⇒ Object (readonly)
Returns the value of attribute final.
5 6 7 |
# File 'lib/gta/stage.rb', line 5 def final @final end |
#hotfixable ⇒ Object (readonly)
Returns the value of attribute hotfixable.
5 6 7 |
# File 'lib/gta/stage.rb', line 5 def hotfixable @hotfixable end |
#manager ⇒ Object (readonly)
Returns the value of attribute manager.
5 6 7 |
# File 'lib/gta/stage.rb', line 5 def manager @manager end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/gta/stage.rb', line 5 def name @name end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
5 6 7 |
# File 'lib/gta/stage.rb', line 5 def repository @repository end |
#restorable ⇒ Object (readonly)
Returns the value of attribute restorable.
5 6 7 |
# File 'lib/gta/stage.rb', line 5 def restorable @restorable end |
#source_name ⇒ Object (readonly)
Returns the value of attribute source_name.
5 6 7 |
# File 'lib/gta/stage.rb', line 5 def source_name @source_name end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
5 6 7 |
# File 'lib/gta/stage.rb', line 5 def tag @tag end |
Instance Method Details
#==(other) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/gta/stage.rb', line 78 def ==(other) other.is_a?(self.class) && name == other.name && branch == other.branch && tag == other.tag end |
#add_remote ⇒ Object
28 29 30 31 32 33 |
# File 'lib/gta/stage.rb', line 28 def add_remote raise "no name defined for #{self}" unless name raise "no repository defined for #{name}" unless repository sh("git remote add #{name} #{repository}") end |
#checkout ⇒ Object
35 36 37 38 |
# File 'lib/gta/stage.rb', line 35 def checkout delete_existing_branch if existing_branch? sh(checkout_command) end |
#checkout! ⇒ Object
40 41 42 43 |
# File 'lib/gta/stage.rb', line 40 def checkout! delete_existing_branch if existing_branch? sh!(checkout_command) end |
#checkout_command ⇒ Object
45 46 47 |
# File 'lib/gta/stage.rb', line 45 def checkout_command "git checkout -b #{name} -t #{name}/#{branch}" end |
#delete_existing_branch ⇒ Object
69 70 71 72 |
# File 'lib/gta/stage.rb', line 69 def delete_existing_branch sh("git checkout master") # in case already on branch sh("git branch -D #{name}") end |
#existing_branch? ⇒ Boolean
74 75 76 |
# File 'lib/gta/stage.rb', line 74 def existing_branch? sh('git branch').include?(name) end |
#fetch ⇒ Object
57 58 59 |
# File 'lib/gta/stage.rb', line 57 def fetch sh(fetch_command) end |
#fetch! ⇒ Object
61 62 63 |
# File 'lib/gta/stage.rb', line 61 def fetch! sh!(fetch_command) end |
#fetch_command ⇒ Object
65 66 67 |
# File 'lib/gta/stage.rb', line 65 def fetch_command "git fetch #{name}" end |
#final? ⇒ Boolean
85 86 87 |
# File 'lib/gta/stage.rb', line 85 def final? !!final end |
#force_push(s = source) ⇒ Object
53 54 55 |
# File 'lib/gta/stage.rb', line 53 def force_push(s=source) sh!(push_command(source_from(s), :force)) end |
#hotfixable? ⇒ Boolean
93 94 95 |
# File 'lib/gta/stage.rb', line 93 def hotfixable? !!hotfixable end |
#push(s = source, forced = nil) ⇒ Object
49 50 51 |
# File 'lib/gta/stage.rb', line 49 def push(s=source, forced=nil) sh!(push_command(source_from(s), forced)) end |
#push_command(source_ref, forced = nil) ⇒ Object
107 108 109 110 |
# File 'lib/gta/stage.rb', line 107 def push_command(source_ref, forced=nil) force = forced == :force ? " -f" : "" "git push#{force} #{name} #{source_ref}:#{branch}" end |
#restorable? ⇒ Boolean
89 90 91 |
# File 'lib/gta/stage.rb', line 89 def restorable? !!restorable end |
#source ⇒ Object
24 25 26 |
# File 'lib/gta/stage.rb', line 24 def source @source ||= manager.stage!(source_name) end |
#source_from(s) ⇒ Object
99 100 101 |
# File 'lib/gta/stage.rb', line 99 def source_from(s) s.respond_to?(:source_ref) ? s.source_ref : s end |
#source_ref ⇒ Object
103 104 105 |
# File 'lib/gta/stage.rb', line 103 def source_ref TagFinder.new(tag).newest || "#{name}" end |
#stages ⇒ Object
20 21 22 |
# File 'lib/gta/stage.rb', line 20 def stages manager.stages end |