aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2016-09-09 08:30:26 +0100
committerGitHub2016-09-09 08:30:26 +0100
commit930bcb7c52523a1e03a1de132192ad4cdd74ce7a (patch)
treec91de0dfb23f75507005deccbc1cd51458aad66d /Library
parent1d66cdd3ade841c6b7cd8a71d4b71d5426d00a58 (diff)
parent027086d67386a58b06f3df92b9168dcb0319ef0e (diff)
downloadbrew-930bcb7c52523a1e03a1de132192ad4cdd74ce7a.tar.bz2
Merge pull request #881 from MikeMcQuaid/dev-cmd-sticky-homebrew-developer
Set HOMEBREW_DEVELOPER automatically
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/brew.rb7
-rw-r--r--Library/Homebrew/brew.sh17
-rw-r--r--Library/Homebrew/cmd/command.rb17
-rw-r--r--Library/Homebrew/cmd/commands.rb8
-rw-r--r--Library/Homebrew/cmd/help.rb18
-rw-r--r--Library/Homebrew/cmd/update.sh14
-rw-r--r--Library/Homebrew/commands.rb13
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb (renamed from Library/Homebrew/cmd/audit.rb)0
-rw-r--r--Library/Homebrew/dev-cmd/bottle.rb (renamed from Library/Homebrew/cmd/bottle.rb)1
-rw-r--r--Library/Homebrew/dev-cmd/create.rb (renamed from Library/Homebrew/cmd/create.rb)0
-rw-r--r--Library/Homebrew/dev-cmd/edit.rb (renamed from Library/Homebrew/cmd/edit.rb)0
-rw-r--r--Library/Homebrew/dev-cmd/man.rb (renamed from Library/Homebrew/cmd/man.rb)15
-rw-r--r--Library/Homebrew/dev-cmd/pull.rb (renamed from Library/Homebrew/cmd/pull.rb)2
-rw-r--r--Library/Homebrew/dev-cmd/tap-readme.rb (renamed from Library/Homebrew/cmd/tap-readme.rb)1
-rw-r--r--Library/Homebrew/dev-cmd/test.rb (renamed from Library/Homebrew/cmd/test.rb)0
-rw-r--r--Library/Homebrew/dev-cmd/tests.rb (renamed from Library/Homebrew/cmd/tests.rb)1
-rw-r--r--Library/Homebrew/dev-cmd/update-test.rb1
-rw-r--r--Library/Homebrew/manpages/brew.1.md.erb4
-rw-r--r--Library/Homebrew/test/test_cmd_audit.rb2
-rw-r--r--Library/Homebrew/test/test_commands.rb18
20 files changed, 78 insertions, 61 deletions
diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb
index 78c8ee5f5..ee7035009 100644
--- a/Library/Homebrew/brew.rb
+++ b/Library/Homebrew/brew.rb
@@ -64,8 +64,13 @@ begin
if cmd
internal_cmd = require? HOMEBREW_LIBRARY_PATH.join("cmd", cmd)
- if !internal_cmd && ARGV.homebrew_developer?
+ unless internal_cmd
internal_cmd = require? HOMEBREW_LIBRARY_PATH.join("dev-cmd", cmd)
+ if internal_cmd && !ARGV.homebrew_developer?
+ safe_system "git", "config", "--file=#{HOMEBREW_REPOSITORY}/.git/config",
+ "--replace-all", "homebrew.devcmdrun", "true"
+ ENV["HOMEBREW_DEV_CMD_RUN"] = "1"
+ end
end
end
diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh
index 1651e8262..70a23a39c 100644
--- a/Library/Homebrew/brew.sh
+++ b/Library/Homebrew/brew.sh
@@ -191,11 +191,26 @@ case "$HOMEBREW_COMMAND" in
--config) HOMEBREW_COMMAND="config" ;;
esac
+if [[ -z "$HOMEBREW_DEVELOPER" ]]
+then
+ export HOMEBREW_GIT_CONFIG_FILE="$HOMEBREW_REPOSITORY/.git/config"
+ HOMEBREW_GIT_CONFIG_DEVELOPERMODE="$(git config --file="$HOMEBREW_GIT_CONFIG_FILE" --get homebrew.devcmdrun)"
+ if [[ "$HOMEBREW_GIT_CONFIG_DEVELOPERMODE" = "true" ]]
+ then
+ export HOMEBREW_DEV_CMD_RUN="1"
+ fi
+fi
+
if [[ -f "$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" ]]
then
HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh"
-elif [[ -n "$HOMEBREW_DEVELOPER" && -f "$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh" ]]
+elif [[ -f "$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh" ]]
then
+ if [[ -z "$HOMEBREW_DEVELOPER" ]]
+ then
+ git config --file="$HOMEBREW_GIT_CONFIG_FILE" --replace-all homebrew.devcmdrun true
+ export HOMEBREW_DEV_CMD_RUN="1"
+ fi
HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh"
fi
diff --git a/Library/Homebrew/cmd/command.rb b/Library/Homebrew/cmd/command.rb
index 8c8a8c699..b76468f62 100644
--- a/Library/Homebrew/cmd/command.rb
+++ b/Library/Homebrew/cmd/command.rb
@@ -1,13 +1,15 @@
#: * `command` <cmd>:
#: Display the path to the file which is used when invoking `brew` <cmd>.
+require "commands"
+
module Homebrew
def command
abort "This command requires a command argument" if ARGV.empty?
cmd = ARGV.first
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd)
- if (path = internal_command_path cmd)
+ if (path = Commands.path(cmd))
puts path
elsif (path = which("brew-#{cmd}") || which("brew-#{cmd}.rb"))
puts path
@@ -15,17 +17,4 @@ module Homebrew
odie "Unknown command: #{cmd}"
end
end
-
- private
-
- def internal_command_path(cmd)
- extensions = %w[rb sh]
- paths = extensions.map { |ext| HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.#{ext}" }
-
- if ARGV.homebrew_developer?
- paths += extensions.map { |ext| HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.#{ext}" }
- end
-
- paths.find { |p| p.file? }
- end
end
diff --git a/Library/Homebrew/cmd/commands.rb b/Library/Homebrew/cmd/commands.rb
index 52705c58a..b8407d668 100644
--- a/Library/Homebrew/cmd/commands.rb
+++ b/Library/Homebrew/cmd/commands.rb
@@ -8,7 +8,7 @@ module Homebrew
def commands
if ARGV.include? "--quiet"
cmds = internal_commands + external_commands
- cmds += internal_development_commands if ARGV.homebrew_developer?
+ cmds += internal_developer_commands
cmds += HOMEBREW_INTERNAL_COMMAND_ALIASES.keys if ARGV.include? "--include-aliases"
puts_columns cmds.sort
else
@@ -19,8 +19,8 @@ module Homebrew
# Find commands in Homebrew/dev-cmd
if ARGV.homebrew_developer?
puts
- puts "Built-in development commands"
- puts_columns internal_development_commands
+ puts "Built-in developer commands"
+ puts_columns internal_developer_commands
end
# Find commands in the path
@@ -36,7 +36,7 @@ module Homebrew
find_internal_commands HOMEBREW_LIBRARY_PATH/"cmd"
end
- def internal_development_commands
+ def internal_developer_commands
find_internal_commands HOMEBREW_LIBRARY_PATH/"dev-cmd"
end
diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb
index ac5fce5b7..1456becb2 100644
--- a/Library/Homebrew/cmd/help.rb
+++ b/Library/Homebrew/cmd/help.rb
@@ -13,7 +13,7 @@ Troubleshooting:
brew doctor
brew install -vd FORMULA
-Brewing:
+Developers:
brew create [URL [--no-fetch]]
brew edit [FORMULA...]
https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Formula-Cookbook.md
@@ -31,12 +31,14 @@ EOS
# NOTE Keep lines less than 80 characters! Wrapping is just not cricket.
# NOTE The reason the string is at the top is so 25 lines is easy to measure!
+require "commands"
+
module Homebrew
def help(cmd = nil, flags = {})
# Resolve command aliases and find file containing the implementation.
if cmd
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd)
- path = command_path(cmd)
+ path = Commands.path(cmd)
end
# Display command-specific (or generic) help in response to `UsageError`.
@@ -69,18 +71,6 @@ module Homebrew
private
- def command_path(cmd)
- if File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh")
- HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh"
- elsif ARGV.homebrew_developer? && File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh")
- HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh"
- elsif File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb")
- HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb"
- elsif ARGV.homebrew_developer? && File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb")
- HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb"
- end
- end
-
def command_help(path)
help_lines = path.read.lines.grep(/^#:/)
if help_lines.empty?
diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh
index ed51444c5..c87c16a11 100644
--- a/Library/Homebrew/cmd/update.sh
+++ b/Library/Homebrew/cmd/update.sh
@@ -159,7 +159,7 @@ reset_on_interrupt() {
git reset --hard "$INITIAL_REVISION" "${QUIET_ARGS[@]}"
fi
- if [[ -n "$HOMEBREW_DEVELOPER" ]]
+ if [[ -n "$HOMEBREW_NO_UPDATE_CLEANUP" ]]
then
pop_stash
else
@@ -243,7 +243,7 @@ EOS
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
then
- if [[ -z "$HOMEBREW_DEVELOPER" ]]
+ if [[ -z "$HOMEBREW_NO_UPDATE_CLEANUP" ]]
then
echo "Checking out $UPSTREAM_BRANCH in $DIR..."
echo "To checkout $INITIAL_BRANCH in $DIR run:"
@@ -286,7 +286,7 @@ EOS
trap '' SIGINT
- if [[ -n "$HOMEBREW_DEVELOPER" ]]
+ if [[ -n "$HOMEBREW_NO_UPDATE_CLEANUP" ]]
then
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
then
@@ -335,6 +335,14 @@ EOS
set -x
fi
+ if [[ -z "$HOMEBREW_UPDATE_CLEANUP" ]]
+ then
+ if [[ -n "$HOMEBREW_DEVELOPER" || -n "$HOMEBREW_DEV_CMD_RUN" ]]
+ then
+ export HOMEBREW_NO_UPDATE_CLEANUP="1"
+ fi
+ fi
+
if [[ -z "$HOMEBREW_AUTO_UPDATE_SECS" ]]
then
HOMEBREW_AUTO_UPDATE_SECS="60"
diff --git a/Library/Homebrew/commands.rb b/Library/Homebrew/commands.rb
new file mode 100644
index 000000000..caf356b43
--- /dev/null
+++ b/Library/Homebrew/commands.rb
@@ -0,0 +1,13 @@
+module Commands
+ def self.path(cmd)
+ if File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh")
+ HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh"
+ elsif File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh")
+ HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh"
+ elsif File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb")
+ HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb"
+ elsif File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb")
+ HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb"
+ end
+ end
+end
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 6d1fa055f..6d1fa055f 100644
--- a/Library/Homebrew/cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb
index 1980fbe9d..1ae44b7e6 100644
--- a/Library/Homebrew/cmd/bottle.rb
+++ b/Library/Homebrew/dev-cmd/bottle.rb
@@ -1,4 +1,3 @@
-#: @hide_from_man_page
#: * `bottle` [`--verbose`] [`--no-rebuild`] [`--keep-old`] [`--skip-relocation`] [`--root-url=<root_url>`]:
#: * `bottle` `--merge` [`--no-commit`] [`--keep-old`] [`--write`]:
#:
diff --git a/Library/Homebrew/cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb
index 9be990318..9be990318 100644
--- a/Library/Homebrew/cmd/create.rb
+++ b/Library/Homebrew/dev-cmd/create.rb
diff --git a/Library/Homebrew/cmd/edit.rb b/Library/Homebrew/dev-cmd/edit.rb
index ef325b8b6..ef325b8b6 100644
--- a/Library/Homebrew/cmd/edit.rb
+++ b/Library/Homebrew/dev-cmd/edit.rb
diff --git a/Library/Homebrew/cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb
index 6754a15f2..fdd4bf33d 100644
--- a/Library/Homebrew/cmd/man.rb
+++ b/Library/Homebrew/dev-cmd/man.rb
@@ -1,4 +1,3 @@
-#: @hide_from_man_page
#: * `man`:
#: Generate Homebrew's manpages.
@@ -34,11 +33,8 @@ module Homebrew
convert_man_page(cask_markup, TARGET_MAN_PATH/"brew-cask.1")
end
- def build_man_page
- template = (SOURCE_PATH/"brew.1.md.erb").read
- variables = OpenStruct.new
-
- variables[:commands] = Pathname.glob("#{HOMEBREW_LIBRARY_PATH}/cmd/*.{rb,sh}").
+ def path_glob_commands(glob)
+ Pathname.glob(glob).
sort_by { |source_file| sort_key_for_path(source_file) }.
map { |source_file|
source_file.read.lines.
@@ -47,7 +43,14 @@ module Homebrew
join
}.
reject { |s| s.strip.empty? || s.include?("@hide_from_man_page") }
+ end
+
+ def build_man_page
+ template = (SOURCE_PATH/"brew.1.md.erb").read
+ variables = OpenStruct.new
+ variables[:commands] = path_glob_commands("#{HOMEBREW_LIBRARY_PATH}/cmd/*.{rb,sh}")
+ variables[:developer_commands] = path_glob_commands("#{HOMEBREW_LIBRARY_PATH}/dev-cmd/*.{rb,sh}")
variables[:maintainers] = (HOMEBREW_REPOSITORY/"README.md").
read[/Homebrew's current maintainers are (.*)\./, 1].
scan(/\[([^\]]*)\]/).flatten
diff --git a/Library/Homebrew/cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb
index 341eed34a..e18bf1c2f 100644
--- a/Library/Homebrew/cmd/pull.rb
+++ b/Library/Homebrew/dev-cmd/pull.rb
@@ -1,10 +1,8 @@
-#: @hide_from_man_page
#: `pull` [`--bottle`] [`--bump`] [`--clean`] [`--ignore-whitespace`] [`--resolve`] [`--branch-okay`] [`--no-pbcopy`] [`--no-publish`] <patch-source> [<patch-source>]
#:
#: Gets a patch from a GitHub commit or pull request and applies it to Homebrew.
#: Optionally, installs the formulae changed by the patch.
#:
-#:
#: Each <patch-source> may be one of:
#: * The ID number of a PR (Pull Request) in the homebrew/core GitHub
#: repository
diff --git a/Library/Homebrew/cmd/tap-readme.rb b/Library/Homebrew/dev-cmd/tap-readme.rb
index ad115a53e..f88d43389 100644
--- a/Library/Homebrew/cmd/tap-readme.rb
+++ b/Library/Homebrew/dev-cmd/tap-readme.rb
@@ -1,4 +1,3 @@
-#: @hide_from_man_page
#: * `tap_readme` [`-v`] <name>:
#: Generate the README.md file for a new tap.
diff --git a/Library/Homebrew/cmd/test.rb b/Library/Homebrew/dev-cmd/test.rb
index a80fa5e4f..a80fa5e4f 100644
--- a/Library/Homebrew/cmd/test.rb
+++ b/Library/Homebrew/dev-cmd/test.rb
diff --git a/Library/Homebrew/cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb
index be8f72ace..bd845e434 100644
--- a/Library/Homebrew/cmd/tests.rb
+++ b/Library/Homebrew/dev-cmd/tests.rb
@@ -1,4 +1,3 @@
-#: @hide_from_man_page
#: * `tests` [`-v`] [`--coverage`] [`--generic`] [`--no-compat`] [`--only=`<test_script/test_method>] [`--seed` <seed>] [`--trace`] [`--online`] [`--official-cmd-taps`]:
#: Run Homebrew's unit and integration tests.
diff --git a/Library/Homebrew/dev-cmd/update-test.rb b/Library/Homebrew/dev-cmd/update-test.rb
index 1f8d0510b..fe0b1bf4d 100644
--- a/Library/Homebrew/dev-cmd/update-test.rb
+++ b/Library/Homebrew/dev-cmd/update-test.rb
@@ -1,4 +1,3 @@
-#: @hide_from_man_page
#: * `update-test` [`--commit=<sha1>`] [`--before=<date>`] [`--keep-tmp`]:
#: Runs a test of `brew update` with a new repository clone.
#:
diff --git a/Library/Homebrew/manpages/brew.1.md.erb b/Library/Homebrew/manpages/brew.1.md.erb
index 60557173d..d6828e9d0 100644
--- a/Library/Homebrew/manpages/brew.1.md.erb
+++ b/Library/Homebrew/manpages/brew.1.md.erb
@@ -50,6 +50,10 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
<%= commands.join("\n") %>
+## DEVELOPER COMMANDS
+
+<%= developer_commands.join("\n") %>
+
## EXTERNAL COMMANDS
Homebrew, like `git`(1), supports external commands. These are executable
diff --git a/Library/Homebrew/test/test_cmd_audit.rb b/Library/Homebrew/test/test_cmd_audit.rb
index 1a52fa628..57d4e754f 100644
--- a/Library/Homebrew/test/test_cmd_audit.rb
+++ b/Library/Homebrew/test/test_cmd_audit.rb
@@ -2,7 +2,7 @@ require "testing_env"
require "fileutils"
require "pathname"
require "formulary"
-require "cmd/audit"
+require "dev-cmd/audit"
class FormulaTextTests < Homebrew::TestCase
def setup
diff --git a/Library/Homebrew/test/test_commands.rb b/Library/Homebrew/test/test_commands.rb
index b6dd5c2be..c51e81559 100644
--- a/Library/Homebrew/test/test_commands.rb
+++ b/Library/Homebrew/test/test_commands.rb
@@ -29,8 +29,8 @@ class CommandsTests < Homebrew::TestCase
refute cmds.include?("rbdevcmd"), "Dev commands shouldn't be included"
end
- def test_internal_development_commands
- cmds = Homebrew.internal_development_commands
+ def test_internal_developer_commands
+ cmds = Homebrew.internal_developer_commands
assert cmds.include?("rbdevcmd"), "Ruby commands files should be recognized"
assert cmds.include?("shdevcmd"), "Shell commands files should be recognized"
refute cmds.include?("rbcmd"), "Non-dev commands shouldn't be included"
@@ -63,20 +63,16 @@ class CommandsTests < Homebrew::TestCase
def test_internal_command_path
assert_equal HOMEBREW_LIBRARY_PATH/"cmd/rbcmd.rb",
- Homebrew.send(:internal_command_path, "rbcmd")
+ Commands.path("rbcmd")
assert_equal HOMEBREW_LIBRARY_PATH/"cmd/shcmd.sh",
- Homebrew.send(:internal_command_path, "shcmd")
- assert_nil Homebrew.send(:internal_command_path, "idontexist1234")
+ Commands.path("shcmd")
+ assert_nil Commands.path("idontexist1234")
end
def test_internal_dev_command_path
- ARGV.stubs(:homebrew_developer?).returns false
- assert_nil Homebrew.send(:internal_command_path, "rbdevcmd")
-
- ARGV.stubs(:homebrew_developer?).returns true
assert_equal HOMEBREW_LIBRARY_PATH/"dev-cmd/rbdevcmd.rb",
- Homebrew.send(:internal_command_path, "rbdevcmd")
+ Commands.path("rbdevcmd")
assert_equal HOMEBREW_LIBRARY_PATH/"dev-cmd/shdevcmd.sh",
- Homebrew.send(:internal_command_path, "shdevcmd")
+ Commands.path("shdevcmd")
end
end