Class: Homebrew::DevCmd::TapNew Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::TapNew
- Includes:
- FileUtils, SystemCommand::Mixin
- Defined in:
- dev-cmd/tap-new.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/tap_new.rbi
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.
Defined Under Namespace
Classes: Args
Instance Method Summary collapse
- #args ⇒ Homebrew::DevCmd::TapNew::Args private
- #run ⇒ void private
Methods included from SystemCommand::Mixin
#command_sandbox, #system_command, #system_command!
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_once, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_incompatible, #pretty_install_status, #pretty_installed, #pretty_removed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::DevCmd::TapNew::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.
10 |
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/tap_new.rbi', line 10 def args; end |
#run ⇒ void
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.
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'dev-cmd/tap-new.rb', line 35 def run branch = args.branch || "main" tap = args.named.to_taps.fetch(0) odie "Invalid tap name '#{tap}'" unless tap.path.to_s.match?(HOMEBREW_TAP_PATH_REGEX) odie "Tap is already installed!" if tap.installed? titleized_user = tap.user.sub(/\A./, &:upcase) titleized_repository = tap.repository.sub(/\A./, &:upcase) root_url = GitHubPackages.root_url(tap.user, "homebrew-#{tap.repository}") if args.github_packages? (tap.path/"Formula").mkpath (tap.path/"Casks").mkpath readme = <<~MARKDOWN # #{titleized_user} #{titleized_repository} ## How do I install packages? `brew install #{tap}/<package>` You can also run `brew tap #{tap}` and then install by name. If a formula and a cask share a name, use `brew install --cask` to select the cask. Or, in a `brew bundle` `Brewfile`: ```ruby tap "#{tap}" brew "<formula>" cask "<cask>" ``` ## Documentation `brew help`, `man brew` or check [Homebrew's documentation](https://docs.brew.sh). MARKDOWN write_path(tap, "README.md", readme) dependabot_yml = <<~YAML version: 2 updates: - package-ecosystem: github-actions directory: "/" schedule: interval: weekly groups: github-actions: patterns: - "*" YAML tests_yml = render_workflow_template( "tap-new-tests.yml", branch:, github_packages: args.github_packages?, root_url: ) publish_yml = render_workflow_template( "tap-new-publish.yml", branch:, github_packages: args.github_packages? ) autobump_yml = render_workflow_template( "tap-new-autobump.yml", branch:, github_packages: args.github_packages? ) (tap.path/".github/workflows").mkpath write_path(tap, ".github/dependabot.yml", dependabot_yml) write_path(tap, ".github/workflows/tests.yml", tests_yml) write_path(tap, ".github/workflows/publish.yml", publish_yml) write_path(tap, ".github/workflows/autobump.yml", autobump_yml) unless args.no_git? cd tap.path do Utils::Git.set_name_email! Utils::Git.setup_gpg! SystemCommand.safe_system "git", "init", "--initial-branch=#{branch}" system_command!("git", args: ["add", "--all"], print_stdout: true) system_command!("git", args: ["commit", "-m", "Create #{tap} tap"], print_stdout: true) system_command!("git", args: ["branch", "-m", branch], print_stdout: true) end end ohai "Created #{tap}" puts <<~EOS #{tap.path} When a cask-only pull request passes CI, you can merge it directly. For formula changes, you can publish the built bottles once CI passes. To do so, run `brew pr-pull` locally or run the `brew pr-pull` workflow with the pull request number and, optionally, the pull request's expected head commit SHA. EOS end |