Add private thor docs:commit

This commit is contained in:
Thibaut Courouble 2016-04-03 09:54:29 -04:00
parent 3317df29c1
commit b5d4875f48
2 changed files with 13 additions and 1 deletions

View file

@ -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

View file

@ -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)