tap-new: add option for branch name

This commit is contained in:
Rylan Polster 2020-10-10 12:28:34 -04:00
parent 77be2c8a56
commit 64d135d0a7
3 changed files with 21 additions and 3 deletions

View File

@ -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

View File

@ -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`*

View File

@ -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\.
.