aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McQuaid2017-03-18 16:57:40 +0200
committerMike McQuaid2017-03-20 18:20:31 +0200
commit623c95b3f8660d5c77936483ec9b9a4db16aff00 (patch)
tree974261d16466928cb033cadc4c49853735baea9d
parent8cedd62750403d7f0c66cbeb714f6da50f50384f (diff)
downloadbrew-623c95b3f8660d5c77936483ec9b9a4db16aff00.tar.bz2
cmd/log: improve output messaging.
This wasn’t adapted to the new, multiple repository world.
-rw-r--r--Library/Homebrew/cmd/log.rb28
-rw-r--r--Library/Homebrew/test/cmd/log_spec.rb2
2 files changed, 21 insertions, 9 deletions
diff --git a/Library/Homebrew/cmd/log.rb b/Library/Homebrew/cmd/log.rb
index 22a3ee11d..9323c762d 100644
--- a/Library/Homebrew/cmd/log.rb
+++ b/Library/Homebrew/cmd/log.rb
@@ -9,20 +9,32 @@ module Homebrew
def log
if ARGV.named.empty?
- cd HOMEBREW_REPOSITORY
- git_log
+ git_log HOMEBREW_REPOSITORY
else
path = Formulary.path(ARGV.named.first)
- cd path.dirname # supports taps
- git_log path
+ tap = Tap.from_path(path)
+ git_log path.dirname, path, tap
end
end
- def git_log(path = nil)
- if File.exist? "#{`git rev-parse --show-toplevel`.chomp}/.git/shallow"
+ def git_log(cd_dir, path = nil, tap = nil)
+ cd cd_dir
+ repo = Utils.popen_read("git rev-parse --show-toplevel").chomp
+ if tap
+ name = tap.to_s
+ git_cd = "$(brew --repo #{tap})"
+ elsif cd_dir == HOMEBREW_REPOSITORY
+ name = "Homebrew/brew"
+ git_cd = "$(brew --repo)"
+ else
+ name, git_cd = cd_dir
+ end
+
+ if File.exist? "#{repo}/.git/shallow"
opoo <<-EOS.undent
- The git repository is a shallow clone therefore the filtering may be incorrect.
- Use `git fetch --unshallow` to get the full repository.
+ #{name} is a shallow clone so only partial output will be shown.
+ To get a full clone run:
+ git -C "#{git_cd}" fetch --unshallow
EOS
end
args = ARGV.options_only
diff --git a/Library/Homebrew/test/cmd/log_spec.rb b/Library/Homebrew/test/cmd/log_spec.rb
index bdbca8912..b9e3e8d3e 100644
--- a/Library/Homebrew/test/cmd/log_spec.rb
+++ b/Library/Homebrew/test/cmd/log_spec.rb
@@ -33,7 +33,7 @@ describe "brew log", :integration_test do
expect { brew "log", "#{shallow_tap}/testball" }
.to output(/This is a test commit for Testball/).to_stdout
- .and output(/Warning: The git repository is a shallow clone/).to_stderr
+ .and output(%r{Warning: homebrew/shallow is a shallow clone}).to_stderr
.and be_a_success
expect(shallow_tap.path/".git/shallow").to exist, "A shallow clone should have been created."