From b5d4875f483a60b164d93760fee048c5b9323729 Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sun, 3 Apr 2016 09:54:29 -0400 Subject: [PATCH] Add private thor docs:commit --- lib/docs.rb | 2 +- lib/tasks/docs.thor | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/docs.rb b/lib/docs.rb index a83ed1c6..2f0d8a29 100644 --- a/lib/docs.rb +++ b/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 diff --git a/lib/tasks/docs.thor b/lib/tasks/docs.thor index e727224e..57dc9ed2 100644 --- a/lib/tasks/docs.thor +++ b/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)