From 0754fabec643c70b258e560a2a7ee2ad0bd2ca9f Mon Sep 17 00:00:00 2001 From: nandahkrishna Date: Tue, 23 Feb 2021 02:45:01 +0530 Subject: [PATCH] dev-cmd/man: modify '--fail-if-changed' to '--fail-if-not-changed' --- .github/workflows/update-manpage.yml | 4 +--- Library/Homebrew/dev-cmd/man.rb | 20 +++++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/update-manpage.yml b/.github/workflows/update-manpage.yml index 90ef5e8606..763105cc7a 100644 --- a/.github/workflows/update-manpage.yml +++ b/.github/workflows/update-manpage.yml @@ -50,9 +50,7 @@ jobs: brew update-maintainers fi - brew man - - if [ -n "$(git status --porcelain=v1 2>/dev/null)" ]; then + if brew man --fail-if-not-changed; then git add "$GITHUB_WORKSPACE/README.md" \ "$GITHUB_WORKSPACE/docs/Manpage.md" \ "$GITHUB_WORKSPACE/manpages/brew.1" \ diff --git a/Library/Homebrew/dev-cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb index a6d12f9981..3d15f07424 100644 --- a/Library/Homebrew/dev-cmd/man.rb +++ b/Library/Homebrew/dev-cmd/man.rb @@ -24,9 +24,9 @@ module Homebrew *Note:* Not (yet) working on Apple Silicon. EOS - switch "--fail-if-changed", - description: "Return a failing status code if changes are detected in the manpage outputs. This "\ - "can be used to notify CI when the manpages are out of date. Additionally, "\ + switch "--fail-if-not-changed", + description: "Return a failing status code if no changes are detected in the manpage outputs. "\ + "This can be used to notify CI when the manpages are out of date. Additionally, "\ "the date used in new manpages will match those in the existing manpages (to allow "\ "comparison without factoring in the date)." named_args :none @@ -42,19 +42,17 @@ module Homebrew args = man_args.parse Commands.rebuild_internal_commands_completion_list - regenerate_man_pages(preserve_date: args.fail_if_changed?, quiet: args.quiet?) + regenerate_man_pages(preserve_date: args.fail_if_not_changed?, quiet: args.quiet?) Completions.update_shell_completions! diff = system_command "git", args: [ "-C", HOMEBREW_REPOSITORY, "diff", "--exit-code", "docs/Manpage.md", "manpages", "completions" ] - if diff.status.success? - puts "No changes to manpage or completions output detected." - elsif args.fail_if_changed? - puts "Changes to manpage or completions detected:" - puts diff.stdout - Homebrew.failed = true - end + + return unless diff.status.success? + + puts "No changes to manpage or completions output detected." + Homebrew.failed = true if args.fail_if_not_changed? end def regenerate_man_pages(preserve_date:, quiet:)