Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tap-new: add option for branch name #8932

Merged
merged 2 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions Library/Homebrew/dev-cmd/tap-new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ def tap_new_args

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
Expand All @@ -27,6 +31,7 @@ def tap_new
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)
Expand Down Expand Up @@ -56,7 +61,7 @@ def tap_new
name: brew test-bot
on:
push:
branches: master
branches: #{branch}
pull_request:
jobs:
test-bot:
Expand Down Expand Up @@ -106,7 +111,7 @@ def tap_new
- 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
Expand All @@ -125,6 +130,7 @@ def tap_new
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
Expand All @@ -142,6 +148,7 @@ def tap_new
safe_system "git", "init"
safe_system "git", "add", "--all"
safe_system "git", "commit", "-m", "Create #{tap} tap"
safe_system "git", "branch", "-m", branch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better specify -b flag for git init directly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had it this way initially but tests failed. I think the -b flag is a new feature that isn't available in the system versions of git

end
end

Expand Down
2 changes: 2 additions & 0 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`*

Expand Down
4 changes: 4 additions & 0 deletions manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -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\.
.
Expand Down