Skip to content

Commit

Permalink
Rename tap-readme command to tap-new.
Browse files Browse the repository at this point in the history
Write the README but also a `.travis.yml` file (and in future perhaps a
`Jenkinsfile`).
  • Loading branch information
MikeMcQuaid committed Oct 15, 2016
1 parent 1327640 commit f435adc
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 45 deletions.
80 changes: 80 additions & 0 deletions Library/Homebrew/dev-cmd/tap-new.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#: * `tap-new` <user>`/`<repo>:
#: Generate the template files for a new tap.

require "tap"

module Homebrew
module_function

def write_path(tap, filename, content)
path = tap.path/filename
tap.path.mkpath
raise "#{path} already exists" if path.exist?
path.write content
end

def tap_new
raise "A tap argument is required" if ARGV.named.empty?

tap = Tap.fetch(ARGV.named.first)
titleized_user = tap.user.dup
titleized_repo = tap.repo.dup
titleized_user[0] = titleized_user[0].upcase
titleized_repo[0] = titleized_repo[0].upcase

(tap.path/"Formula").mkpath

readme = <<-EOS.undent
# #{titleized_user} #{titleized_repo}
## How do I install these formulae?
`brew install #{tap}/<formula>`
Or `brew tap #{tap}` and then `brew install <formula>`.
Or install via URL (which will not receive updates):
```
brew install https://raw.githubusercontent.com/#{tap.user}/homebrew-#{tap.repo}/master/Formula/<formula>.rb
```
## Documentation
`brew help`, `man brew` or check [Homebrew's documentation](https://github.com/Homebrew/brew/tree/master/docs#readme).
EOS
write_path(tap, "README.md", readme)

travis = <<-EOS.undent
language: ruby
os: osx
env: OSX=10.11
osx_image: xcode7.3
rvm: system
before_install:
- export TRAVIS_COMMIT="$(git rev-parse --verify -q HEAD)"
- if [ -f ".git/shallow" ]; then
travis_retry git fetch --unshallow;
fi
- sudo chown -R $USER "$(brew --repo)"
- git -C "$(brew --repo)" reset --hard origin/master
- git -C "$(brew --repo)" clean -qxdff
- brew update || brew update
- rm -rf "$(brew --repo $TRAVIS_REPO_SLUG)"
- mkdir -p "$(brew --repo $TRAVIS_REPO_SLUG)"
- rsync -az "$TRAVIS_BUILD_DIR/" "$(brew --repo $TRAVIS_REPO_SLUG)"
- export TRAVIS_BUILD_DIR="$(brew --repo $TRAVIS_REPO_SLUG)"
- cd "$(brew --repo)"
- export HOMEBREW_DEVELOPER="1"
- ulimit -n 1024
script:
- brew test-bot
notifications:
email:
on_success: never
on_failure: always
EOS
write_path(tap, ".travis.yml", travis)
end
end
37 changes: 0 additions & 37 deletions Library/Homebrew/dev-cmd/tap-readme.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
require "helper/integration_command_test_case"

class IntegrationCommandTestTapReadme < IntegrationCommandTestCase
class IntegrationCommandTestTapNew < IntegrationCommandTestCase
def test_tap_readme
assert_match "brew install homebrew/foo/<formula>",
cmd("tap-readme", "foo", "--verbose")
assert_equal "", cmd("tap-new", "homebrew/foo", "--verbose")
readme = HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo/README.md"
assert readme.exist?, "The README should be created"
end
Expand Down
4 changes: 2 additions & 2 deletions completions/bash/brew
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ _brew_tap_info() {
__brew_complete_tapped
}

_brew_tap_readme() {
_brew_tap_new() {
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
Expand Down Expand Up @@ -612,7 +612,7 @@ _brew() {
tap) _brew_tap ;;
tap-info) _brew_tap_info ;;
tap-pin) __brew_complete_tapped ;;
tap-readme) _brew_tap_readme ;;
tap-new) _brew_tap_new ;;
tap-unpin) _brew_tap_unpin ;;
test) __brew_complete_installed ;;
tests) _brew_tests ;;
Expand Down
2 changes: 1 addition & 1 deletion docs/brew.1.html
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ <h2 id="DEVELOPER-COMMANDS">DEVELOPER COMMANDS</h2>
If <code>--no-publish</code> was passed, do not publish bottles to Bintray.</p>

<dl>
<dt><code>tap_readme</code> [<code>-v</code>] <var>name</var></dt><dd><p>Generate the README.md file for a new tap.</p></dd>
<dt><code>tap-new</code> <var>user</var><code>/</code><var>repo</var></dt><dd><p>Generate the template files for a new tap.</p></dd>
<dt><code>test</code> [<code>--devel</code>|<code>--HEAD</code>] [<code>--debug</code>] [<code>--keep-tmp</code>] <var>formula</var></dt><dd><p>Most formulae provide a test method. <code>brew test</code> <var>formula</var> runs this
test method. There is no standard output or return code, but it should
generally indicate to the user if something is wrong with the installed
Expand Down
4 changes: 2 additions & 2 deletions manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,8 @@ Each <patch\-source> may be one of:
If \fB\-\-bottle\fR was passed, handle bottles, pulling the bottle\-update commit and publishing files on Bintray\. If \fB\-\-bump\fR was passed, for one\-formula PRs, automatically reword commit message to our preferred format\. If \fB\-\-clean\fR was passed, do not rewrite or otherwise modify the commits found in the pulled PR\. If \fB\-\-ignore\-whitespace\fR was passed, silently ignore whitespace discrepancies when applying diffs\. If \fB\-\-resolve\fR was passed, when a patch fails to apply, leave in progress and allow user to resolve, instead of aborting\. If \fB\-\-branch\-okay\fR was passed, do not warn if pulling to a branch besides master (useful for testing)\. If \fB\-\-no\-pbcopy\fR was passed, do not copy anything to the system If \fB\-\-no\-publish\fR was passed, do not publish bottles to Bintray\.
.
.TP
\fBtap_readme\fR [\fB\-v\fR] \fIname\fR
Generate the README\.md file for a new tap\.
\fBtap\-new\fR \fIuser\fR\fB/\fR\fIrepo\fR
Generate the template files for a new tap\.
.
.TP
\fBtest\fR [\fB\-\-devel\fR|\fB\-\-HEAD\fR] [\fB\-\-debug\fR] [\fB\-\-keep\-tmp\fR] \fIformula\fR
Expand Down

0 comments on commit f435adc

Please sign in to comment.