Browse Source

Add private thor docs:commit

Thibaut Courouble 9 years ago
parent
commit
b5d4875f48
2 changed files with 13 additions and 1 deletions
  1. 1 1
      lib/docs.rb
  2. 12 0
      lib/tasks/docs.thor

+ 1 - 1
lib/docs.rb

@@ -58,7 +58,7 @@ module Docs
     if version.present?
       doc = doc.versions.find { |klass| klass.version == version || klass.version_slug == version }
       raise DocNotFound.new(%(could not find version "#{version}" for doc "#{name}"), name) unless doc
-    else
+    elsif version != false
       doc = doc.versions.first
     end
 

+ 12 - 0
lib/tasks/docs.thor

@@ -154,6 +154,18 @@ class DocsCLI < Thor
     end
   end
 
+  desc 'commit', '[private]'
+  option :message, type: :string
+  option :amend, type: :boolean
+  def commit(name)
+    doc = Docs.find(name, false)
+    message = options[:message] || "Update #{doc.name} documentation (#{doc.versions.map(&:release).join(', ')})"
+    amend = " --amend" if options[:amend]
+    system("git add assets/ *#{doc.slug}*") && system("git commit -m '#{message}'#{amend}")
+  rescue Docs::DocNotFound => error
+    handle_doc_not_found_error(error)
+  end
+
   private
 
   def find_docs(names)