Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git

Makes peek default to 255 bytes

AuthorDave Jarvis <email>
Date2026-02-14 14:57:16 GMT-0800
Commit7813282484c27913b18c9a78687f795d6378d36b
Parente8b43bf
File.php
$buffer = $this->isDir ? '' : $contents;
- $this->mediaType = MediaTypeSniffer::isMediaType($buffer, $name);
- $this->category = MediaTypeSniffer::isCategory($buffer, $name);
- $this->binary = MediaTypeSniffer::isBinary($buffer, $name);
+ $this->mediaType = MediaTypeSniffer::isMediaType( $buffer );
+ $this->category = MediaTypeSniffer::isCategory( $buffer, $name );
+ $this->binary = MediaTypeSniffer::isBinary( $buffer );
$this->icon = $this->resolveIcon();
}
MediaTypeSniffer.php
];
- public static function isMediaType(
- string $buffer,
- string $filename = ''
- ): string {
+ public static function isMediaType( string $buffer ): string {
$finfo = new finfo( FILEINFO_MIME_TYPE );
$mediaType = $finfo->buffer( $buffer );
return $mediaType ?: 'application/octet-stream';
}
public static function isCategory(
string $buffer,
string $filename = ''
): string {
- $mediaType = self::isMediaType( $buffer, $filename );
+ $mediaType = self::isMediaType( $buffer );
$parts = explode( '/', $mediaType );
}
- public static function isBinary(
- string $buffer,
- string $filename = ''
- ): bool {
- return !str_starts_with(
- self::isMediaType( $buffer, $filename ),
- 'text/'
- );
+ public static function isBinary( string $buffer ): bool {
+ return !str_starts_with( self::isMediaType( $buffer ), 'text/' );
}
git/Git.php
}
- public function peek( string $sha, int $length = 12 ): string {
+ public function peek( string $sha, int $length = 255 ): string {
$size = $this->packs->getSize( $sha );
$isDirectory = $mode === '40000' || $mode === '040000';
$size = $isDirectory ? 0 : $this->getObjectSize( $sha );
- $contents = $isDirectory ? '' : $this->peek( $sha, 255 );
+ $contents = $isDirectory ? '' : $this->peek( $sha );
$callback( new File( $name, $sha, $mode, 0, $size, $contents ) );
Delta9 lines added, 18 lines removed, 9-line decrease