From 64d135d0a7f242fda9ffd1a007614a6aa960c9d9 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Sat, 10 Oct 2020 12:28:34 -0400 Subject: [PATCH 1/2] tap-new: add option for branch name --- Library/Homebrew/dev-cmd/tap-new.rb | 18 +++++++++++++++--- docs/Manpage.md | 2 ++ manpages/brew.1 | 4 ++++ 3 files changed, 21 insertions(+), 3 deletions(-) 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\. . From 6dec1755742a85139fd0ed60f103db8c1a0e0f08 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Thu, 15 Oct 2020 16:56:53 -0400 Subject: [PATCH 2/2] tap-new: don't need to checkout default branch --- Library/Homebrew/dev-cmd/tap-new.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Library/Homebrew/dev-cmd/tap-new.rb b/Library/Homebrew/dev-cmd/tap-new.rb index 12f21e57d8..d9c9f3b5e8 100644 --- a/Library/Homebrew/dev-cmd/tap-new.rb +++ b/Library/Homebrew/dev-cmd/tap-new.rb @@ -120,11 +120,6 @@ 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 }}