History

Add private thor docs:commit

Thibaut Courouble committed 10 years ago

Commit b5d48751 parent 3317df22 files · +13 −1Browse files

Unified · Split

2 files
  1. lib/docs.rb +1 −1
  2. lib/tasks/docs.thor +12 −0
lib/docs.rb+1−1
@@ -58,7 +58,7 @@ module Docs · 57 unmodified lines
5858 if version.present?
5959 doc = doc.versions.find { |klass| klass.version == version || klass.version_slug == version }
6060 raise DocNotFound.new(%(could not find version "#{version}" for doc "#{name}"), name) unless doc
61− else
61+ elsif version != false
6262 doc = doc.versions.first
6363 end
6464
lib/tasks/docs.thor+12−0
@@ -154,6 +154,18 @@ class DocsCLI < Thor · 153 unmodified lines
154154 end
155155 end
156156
157+ desc 'commit', '[private]'
158+ option :message, type: :string
159+ option :amend, type: :boolean
160+ def commit(name)
161+ doc = Docs.find(name, false)
162+ message = options[:message] || "Update #{doc.name} documentation (#{doc.versions.map(&:release).join(', ')})"
163+ amend = " --amend" if options[:amend]
164+ system("git add assets/ *#{doc.slug}*") && system("git commit -m '#{message}'#{amend}")
165+ rescue Docs::DocNotFound => error
166+ handle_doc_not_found_error(error)
167+ end
168+
157169 private
158170
159171 def find_docs(names)