From 44d13ce2560266eff535208ffc437b0243930ac3 Mon Sep 17 00:00:00 2001 From: Steven Peters Date: Wed, 28 Sep 2016 03:28:20 -0700 Subject: [PATCH] dev-cmd/man: display diff --stat, add --exit-code The --fail-if-changed option will cause `brew man` to return a failing status code if the man files have changed. --- Library/Homebrew/dev-cmd/man.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb index 871fbf46c9..d7f47d199d 100644 --- a/Library/Homebrew/dev-cmd/man.rb +++ b/Library/Homebrew/dev-cmd/man.rb @@ -1,5 +1,9 @@ -#: * `man`: +#: * `man` [`--fail-if-changed`]: #: Generate Homebrew's manpages. +#: +#: If `--fail-if-changed` is passed, the command will return a failing +#: status code if changes are detected in the manpage outputs. +#: This can be used for CI to be notified when the manpages are out of date. require "formula" require "erb" @@ -18,6 +22,12 @@ module Homebrew else regenerate_man_pages end + + if system "git", "-C", HOMEBREW_REPOSITORY, "diff", "--quiet", "docs/brew.1.html", "manpages" + puts "No changes to manpage output detected." + elsif ARGV.include?("--fail-if-changed") + Homebrew.failed = true + end end private