cmd/log: improve output messaging.
This wasn’t adapted to the new, multiple repository world.
This commit is contained in:
		
							parent
							
								
									8cedd62750
								
							
						
					
					
						commit
						623c95b3f8
					
				@ -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
 | 
			
		||||
 | 
			
		||||
@ -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."
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user