Provide a way to read (git)attributes for files
In the context of &9903, the client needs a way to determine a file is "generated". This "generated" flag is determined by go-enry
, or can be set in gitattributes(5)
. Gitaly needs to provide a way to read these attributes for a given set of files.
Proposal
Add a new RPC, for example GetFileAttributes
. The request will contain a list of filenames for which the caller wants to read attributes. The request will also contain a list for which attributes it wants to read. If any of the known linguist-*
attributes is given, Gitaly will also call into go-enry
to have that library check those attributes, but gitattributes(5)
has higher precedence.
The response will stream back a response for each filename and it's attributes.
We probably also need a way to just read all attributes. I assume this would not call into go-enry
, or shall we add an extra bool for this?
Alternatives
Because this is needed on the MR diff page, it will be used in combination with the CommitDiff
RPC. Because the CommitDiffResponse
already has a "collapse" flag, we could extend the handling of that request and make it fill in collapsed
based on the attributes. But would overload the functionality of that RPC, and thus the proposal above is chosen.
Availability and Testing
Add tests in gitaly repo for new RPC.