Class: RightDevelop::Git::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- RightDevelop::Git::RakeTask
- Includes:
- Rake::DSL
- Defined in:
- lib/right_develop/git/rake_task.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :git_namespace => :git, :pre_checkout_step => nil, :post_checkout_step => nil, :pre_verify_step => nil, :post_verify_step => nil, }
Instance Attribute Summary collapse
-
#git_namespace ⇒ Object
Returns the value of attribute git_namespace.
-
#post_checkout_step ⇒ Object
Returns the value of attribute post_checkout_step.
-
#post_verify_step ⇒ Object
Returns the value of attribute post_verify_step.
-
#pre_checkout_step ⇒ Object
Returns the value of attribute pre_checkout_step.
-
#pre_verify_step ⇒ Object
Returns the value of attribute pre_verify_step.
Instance Method Summary collapse
-
#initialize(options = {}) {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/right_develop/git/rake_task.rb', line 47 def initialize( = {}) # Let client provide options object-style, in our initializer = DEFAULT_OPTIONS.merge() self.git_namespace = [:git_namespace] self.pre_checkout_step = [:pre_checkout_step] self.post_checkout_step = [:post_checkout_step] self.pre_verify_step = [:pre_verify_step] self.post_verify_step = [:post_verify_step] # Let client provide options DSL-style by calling our writers yield(self) if block_given? namespace self.git_namespace do desc "Perform 'git submodule update --init --recursive'" task :setup do git.setup end desc "If HEAD is a branch or tag ref, ensure that all submodules are checked out to the same tag or branch or ensure consistency for SHA" task :verify, [:revision, :base_dir] do |_, args| revision = args[:revision].to_s.strip base_dir = args[:base_dir].to_s.strip revision = nil if revision.empty? base_dir = '.' if base_dir.empty? ::Dir.chdir(base_dir) do pre_verify_step.call(revision) if pre_verify_step git.verify_revision(revision) post_verify_step.call(revision) if post_verify_step end end desc "Checkout supermodule and all submodules to given tag, branch or SHA" task :checkout, [:revision, :base_dir] do |_, args| revision = args[:revision].to_s.strip base_dir = args[:base_dir].to_s.strip raise ::ArgumentError, 'revision is required' if revision.empty? base_dir = '.' if base_dir.empty? ::Dir.chdir(base_dir) do pre_checkout_step.call(revision) if pre_checkout_step git.checkout_revision(revision, :force => true, :recursive => true) post_checkout_step.call(revision) if post_checkout_step end end end # namespace end |
Instance Attribute Details
#git_namespace ⇒ Object
Returns the value of attribute git_namespace.
43 44 45 |
# File 'lib/right_develop/git/rake_task.rb', line 43 def git_namespace @git_namespace end |
#post_checkout_step ⇒ Object
Returns the value of attribute post_checkout_step.
44 45 46 |
# File 'lib/right_develop/git/rake_task.rb', line 44 def post_checkout_step @post_checkout_step end |
#post_verify_step ⇒ Object
Returns the value of attribute post_verify_step.
45 46 47 |
# File 'lib/right_develop/git/rake_task.rb', line 45 def post_verify_step @post_verify_step end |
#pre_checkout_step ⇒ Object
Returns the value of attribute pre_checkout_step.
44 45 46 |
# File 'lib/right_develop/git/rake_task.rb', line 44 def pre_checkout_step @pre_checkout_step end |
#pre_verify_step ⇒ Object
Returns the value of attribute pre_verify_step.
45 46 47 |
# File 'lib/right_develop/git/rake_task.rb', line 45 def pre_verify_step @pre_verify_step end |