Merge pull request #1277 from MikeMcQuaid/tap-new-command
Rename tap-readme command to tap-new.
This commit is contained in:
		
						commit
						44822340f2
					
				
							
								
								
									
										80
									
								
								Library/Homebrew/dev-cmd/tap-new.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								Library/Homebrew/dev-cmd/tap-new.rb
									
									
									
									
									
										Normal file
									
								
							@ -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
 | 
			
		||||
@ -1,37 +0,0 @@
 | 
			
		||||
#:  * `tap_readme` [`-v`] <name>:
 | 
			
		||||
#:    Generate the README.md file for a new tap.
 | 
			
		||||
 | 
			
		||||
module Homebrew
 | 
			
		||||
  module_function
 | 
			
		||||
 | 
			
		||||
  def tap_readme
 | 
			
		||||
    name = ARGV.first
 | 
			
		||||
    raise "A name is required" if name.nil?
 | 
			
		||||
 | 
			
		||||
    titleized_name = name.dup
 | 
			
		||||
    titleized_name[0..0] = titleized_name[0..0].upcase
 | 
			
		||||
 | 
			
		||||
    template = <<-EOS.undent
 | 
			
		||||
    # Homebrew #{titleized_name}
 | 
			
		||||
 | 
			
		||||
    ## How do I install these formulae?
 | 
			
		||||
    `brew install homebrew/#{name}/<formula>`
 | 
			
		||||
 | 
			
		||||
    Or `brew tap homebrew/#{name}` and then `brew install <formula>`.
 | 
			
		||||
 | 
			
		||||
    Or install via URL (which will not receive updates):
 | 
			
		||||
 | 
			
		||||
    ```
 | 
			
		||||
    brew install https://raw.githubusercontent.com/Homebrew/homebrew-#{name}/master/<formula>.rb
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
    ## Documentation
 | 
			
		||||
    `brew help`, `man brew` or check [Homebrew's documentation](https://github.com/Homebrew/brew/tree/master/docs#readme).
 | 
			
		||||
    EOS
 | 
			
		||||
 | 
			
		||||
    puts template if ARGV.verbose?
 | 
			
		||||
    path = HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-#{name}/README.md"
 | 
			
		||||
    raise "#{path} already exists" if path.exist?
 | 
			
		||||
    path.write template
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
@ -102,7 +102,7 @@ class IntegrationCommandTestCase < Homebrew::TestCase
 | 
			
		||||
  def cmd(*args)
 | 
			
		||||
    output = cmd_output(*args)
 | 
			
		||||
    status = $?.exitstatus
 | 
			
		||||
    puts "\n#{output}" if status.nonzero?
 | 
			
		||||
    puts "\n'brew #{args.join " "}' output: #{output}" if status.nonzero?
 | 
			
		||||
    assert_equal 0, status
 | 
			
		||||
    output
 | 
			
		||||
  end
 | 
			
		||||
@ -110,7 +110,7 @@ class IntegrationCommandTestCase < Homebrew::TestCase
 | 
			
		||||
  def cmd_fail(*args)
 | 
			
		||||
    output = cmd_output(*args)
 | 
			
		||||
    status = $?.exitstatus
 | 
			
		||||
    $stderr.puts "\n#{output}" if status.zero?
 | 
			
		||||
    $stderr.puts "\n'brew #{args.join " "}'" if status.zero?
 | 
			
		||||
    refute_equal 0, status
 | 
			
		||||
    output
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
@ -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
 | 
			
		||||
    --*)
 | 
			
		||||
@ -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 ;;
 | 
			
		||||
 | 
			
		||||
@ -567,7 +567,7 @@ Each <patch-source> may be one of:
 | 
			
		||||
   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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user