Add Git-LFS support to the GitLab backend
Git-LFS
As of now, only the git-gateway and bitbucket backends support Git-LFS. Expanding the Git-LFS support to the gitlab backend would benefit gitlab users.
The implementation would be similar to the git LFS implementation in the bitbucket backend: https://github.com/netlify/netlify-cms/pull/3118
Has anyone had a look into this? Is it even possible using the GitLab API? The discussion in https://github.com/netlify/netlify-cms/issues/1206#issuecomment-641474201 suggests, that it is not possible for GitHub... but GitLab should be possible, considering https://gitlab.com/gitlab-org/gitlab/-/issues/27892 (even though the issue is still open, the comments suggest that it could be possible).
Hi @knoppiks, if you'd like to look into it, you can use the Bitbucket implementation as a reference: https://github.com/netlify/netlify-cms/blob/8d693caebdda381b989ea9b934fac4e65d06498e/packages/netlify-cms-backend-bitbucket/src/implementation.ts#L379
I took a look at this as I need it too, but currently I don't think it's possible because:
-
There is no
/api/v4endpoint to fetch LFS content. The gitlab API endpoints only return the LFS Pointer files, but it doesn't offer the possibility to get the real content, issue. -
You can get LFS content by communicating with
${PROJECT}.git/endpoints, but they are missing CORS headers, so are not usable, issue.I've got it so far to do requests to fetch the LFS content as described by Markus here. But they fail because those endpoints are not exposing permissive CORS headers. There's an open issue in gitlab for this: https://gitlab.com/gitlab-org/gitlab/-/issues/20590 after that's been solved I think it should be possible to implement this in some way.
When testing this I found that if you upload a LFS file, then publish it, the file actually gets stored as LFS in gitlab, which is fine. But then if you edit some more content in the same file without refreshing, then you publish again, it actually overwrites the LFS file with the 'full blob' file instead. And it's no longer as LFS in the repository.
But when you upload an image, then publish and then immediately refresh, the preview won't work, as gitlab returns the LFS pointer files, but editing and publishing works fine. It will try to publish the pointer file, which is still the same. So the files will actually stay proper LFS files.
So as a workaround the best way currently is to refresh immediately after publishing new LFS files. That will break the previews, but all files will keep being 'proper' LFS files.
Is anyone currently working this issue? This would be a great feature to have.
According to https://gitlab.com/gitlab-org/gitlab/-/issues/27892 a trailing ?lfs=true should be added to the rest call, once the new GitLab version is out. Will try to prepare a PR once I can test it.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I am also interested in in this.
This should now be covered by #7815, which was merged today. The GitLab backend now requests raw LFS media with lfs=true while keeping normal entry reads unchanged.
Leaving this here so maintainers can verify and close if it matches the intended scope.
This is released in [email protected]