diff --git a/Library/Homebrew/dev-cmd/tap-new.rb b/Library/Homebrew/dev-cmd/tap-new.rb index 7b587570be..12f21e57d8 100644 --- a/Library/Homebrew/dev-cmd/tap-new.rb +++ b/Library/Homebrew/dev-cmd/tap-new.rb @@ -17,8 +17,12 @@ module Homebrew switch "--no-git", description: "Don't initialize a git repository for the tap." - flag "--pull-label", + flag "--pull-label=", description: "Label name for pull requests ready to be pulled (default `pr-pull`)." + flag "--branch=", + description: "Initialize git repository with the specified branch name (default `main`)." + + conflicts "--no-git", "--branch" named 1 end end @@ -27,6 +31,7 @@ module Homebrew args = tap_new_args.parse label = args.pull_label || "pr-pull" + branch = args.branch || "main" tap_name = args.named.first tap = Tap.fetch(tap_name) @@ -56,7 +61,7 @@ module Homebrew name: brew test-bot on: push: - branches: master + branches: #{branch} pull_request: jobs: test-bot: @@ -106,7 +111,7 @@ module Homebrew - labeled jobs: pr-pull: - if: contains(github.event.pull_request.labels.*.name, #{label}) + if: contains(github.event.pull_request.labels.*.name, '#{label}') runs-on: ubuntu-latest steps: - name: Set up Homebrew @@ -115,6 +120,11 @@ module Homebrew - name: Set up git uses: Homebrew/actions/git-user-config@master + - name: Checkout default branch + env: + BRANCH: ${{ github.event.pull_request.head.repo.default_branch }} + run: git checkout $BRANCH + - name: Pull bottles env: HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }} @@ -125,6 +135,7 @@ module Homebrew uses: Homebrew/actions/git-try-push@master with: token: ${{ github.token }} + branch: #{branch} - name: Delete branch if: github.event.pull_request.head.repo.fork == false @@ -142,6 +153,7 @@ module Homebrew safe_system "git", "init" safe_system "git", "add", "--all" safe_system "git", "commit", "-m", "Create #{tap} tap" + safe_system "git", "branch", "-m", branch end end diff --git a/docs/Manpage.md b/docs/Manpage.md index 3d2d523253..2753f53c5a 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -1231,6 +1231,8 @@ Generate the template files for a new tap. Don't initialize a git repository for the tap. * `--pull-label`: Label name for pull requests ready to be pulled (default `pr-pull`). +* `--branch`: + Initialize git repository with the specified branch name (default `main`). ### `test` [*`options`*] *`formula`* diff --git a/manpages/brew.1 b/manpages/brew.1 index 6d57c7068e..9b8b334d5a 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1708,6 +1708,10 @@ Don\'t initialize a git repository for the tap\. \fB\-\-pull\-label\fR Label name for pull requests ready to be pulled (default \fBpr\-pull\fR)\. . +.TP +\fB\-\-branch\fR +Initialize git repository with the specified branch name (default \fBmain\fR)\. +. .SS "\fBtest\fR [\fIoptions\fR] \fIformula\fR" Run the test method provided by an installed formula\. There is no standard output or return code, but generally it should notify the user if something is wrong with the installed formula\. .