Skip to content

Commit b5d4875

Browse files
committed
Add private thor docs:commit
1 parent 3317df2 commit b5d4875

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/docs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def self.find(name, version = nil)
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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ class DocsCLI < Thor
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)

0 commit comments

Comments
 (0)