Skip to content

Use git binary assigment #218

Closed
Closed

Description

@Patrick-Beuks

At the moment this library uses the mimetype to determine if a file is a text file
https://github.com/gitonomy/gitlib/blob/main/src/Gitonomy/Git/Blob.php#L106

This make for example the mimetype application/json be a binary type.

Git has build-in binary assignment for file. If possible it would be nice to use this.

One way to do it is with the git ls-files command

git ls-files <filePath> --eol --with-tree=<branch|commit|tree>

A normal file would output:

git ls-files composer.json --eol --with-tree=HEAD
i/lf    w/lf    attr/                   composer.json

A binary file would output:

git ls-files a.out --eol --with-tree=main
i/-text w/-text attr/                   a.out

Notice the -text attrubutes

Activity

  1. lyrixx commented on Apr 23, 2024

    @lyrixx
    Member

    Would you mind to submit a PR?

  2. Patrick-Beuks commented on Apr 23, 2024

    @Patrick-Beuks
    ContributorAuthor

    Created a PR. As stated in the PR instead of using the ls-files route it uses the direct implementation git uses to determine if content is binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions