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
58 if version.present?58 if version.present?
59 doc = doc.versions.find { |klass| klass.version == version || klass.version_slug == version }59 doc = doc.versions.find { |klass| klass.version == version || klass.version_slug == version }
60 raise DocNotFound.new(%(could not find version "#{version}" for doc "#{name}"), name) unless doc60 raise DocNotFound.new(%(could not find version "#{version}" for doc "#{name}"), name) unless doc
61 else61 elsif version != false
62 doc = doc.versions.first62 doc = doc.versions.first
63 end63 end
64 64
lib/tasks/docs.thor+12−0
@@ -154,6 +154,18 @@ class DocsCLI < Thor · 153 unmodified lines
154 end154 end
155 end155 end
156 156
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
157 private169 private
158 170
159 def find_docs(names)171 def find_docs(names)