cmd/log: various fixes.
- Don't pass through `args:` when called with no arguments; these don'T need to be passed and end up breaking things instead. - Make `T.must` as early as possible. - Add a type signature to `git_log` to enable `typed: strict` and catch these sorts of bugs earlier next time. - `--follow` only works with a single file so check if the path is a file before adding it to the arguments.
This commit is contained in:
		
							parent
							
								
									56fc9a1fb2
								
							
						
					
					
						commit
						7bfe859473
					
				@ -42,16 +42,17 @@ module Homebrew
 | 
			
		||||
        ENV["PATH"] = PATH.new(ORIGINAL_PATHS).to_s
 | 
			
		||||
 | 
			
		||||
        if args.no_named?
 | 
			
		||||
          git_log(HOMEBREW_REPOSITORY, args:)
 | 
			
		||||
          git_log(HOMEBREW_REPOSITORY)
 | 
			
		||||
        else
 | 
			
		||||
          path = args.named.to_paths.first
 | 
			
		||||
          path = T.must(args.named.to_paths.first)
 | 
			
		||||
          tap = Tap.from_path(path)
 | 
			
		||||
          git_log T.must(path).dirname, path, tap
 | 
			
		||||
          git_log path.dirname, path, tap
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      private
 | 
			
		||||
 | 
			
		||||
      sig { params(cd_dir: Pathname, path: T.nilable(Pathname), tap: T.nilable(Tap)).void }
 | 
			
		||||
      def git_log(cd_dir, path = nil, tap = nil)
 | 
			
		||||
        cd cd_dir do
 | 
			
		||||
          repo = Utils.popen_read("git", "rev-parse", "--show-toplevel").chomp
 | 
			
		||||
@ -79,7 +80,7 @@ module Homebrew
 | 
			
		||||
          git_args << "--oneline" if args.oneline?
 | 
			
		||||
          git_args << "-1" if args.public_send(:"1?")
 | 
			
		||||
          git_args << "--max-count" << args.max_count if args.max_count
 | 
			
		||||
          git_args += ["--follow", "--", path] if path.present?
 | 
			
		||||
          git_args += ["--follow", "--", path] if path&.file?
 | 
			
		||||
          system "git", "log", *git_args
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user