Class: Homebrew::DevCmd::BumpRevision Private

Inherits:
AbstractCommand show all
Defined in:
sorbet/rbi/dsl/homebrew/dev_cmd/bump_revision.rbi,
dev-cmd/bump-revision.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

DO NOT EDIT MANUALLY This is an autogenerated file for dynamic methods in Homebrew::DevCmd::BumpRevision. Please instead update this file by running bin/tapioca dsl Homebrew::DevCmd::BumpRevision.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::BumpRevision::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



9
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/bump_revision.rbi', line 9

def args; end

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'dev-cmd/bump-revision.rb', line 30

def run
  # As this command is simplifying user-run commands then let's just use a
  # user path, too.
  ENV["PATH"] = PATH.new(ORIGINAL_PATHS).to_s

  Homebrew.install_bundler_gems!(groups: ["ast"]) unless args.dry_run?

  args.named.to_formulae.each do |formula|
    current_revision = formula.revision
    new_revision = current_revision + 1

    if args.dry_run?
      unless args.quiet?
        old_text = "revision #{current_revision}"
        new_text = "revision #{new_revision}"
        if current_revision.zero?
          ohai "add #{new_text.inspect}"
        else
          ohai "replace #{old_text.inspect} with #{new_text.inspect}"
        end
      end
    else
      require "utils/ast"

      formula_ast = Utils::AST::FormulaAST.new(formula.path.read)
      if current_revision.zero?
        formula_ast.add_stanza(:revision, new_revision)
      else
        formula_ast.replace_stanza(:revision, new_revision)
      end
      formula_ast.remove_stanza(:bottle) if args.remove_bottle_block?
      formula.path.atomic_write(formula_ast.process)
    end

    message = "#{formula.name}: revision bump #{args.message}"
    if args.dry_run?
      ohai "git commit --no-edit --verbose --message=#{message} -- #{formula.path}"
    elsif !args.write_only?
      formula.path.parent.cd do
        safe_system "git", "commit", "--no-edit", "--verbose",
                    "--message=#{message}", "--", formula.path
      end
    end
  end
end