decap-cms icon indicating copy to clipboard operation
decap-cms copied to clipboard

Add Git-LFS support to the GitLab backend

Open skafendre opened this issue 6 years ago • 9 comments

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

skafendre avatar May 05 '20 10:05 skafendre

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).

knoppiks avatar Aug 29 '20 18:08 knoppiks

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

erezrokah avatar Aug 30 '20 13:08 erezrokah

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/v4 endpoint 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.

MarijnKoesen avatar Dec 27 '20 10:12 MarijnKoesen

Is anyone currently working this issue? This would be a great feature to have.

nibbleshift avatar Feb 21 '21 14:02 nibbleshift

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.

SebiGo avatar Nov 30 '22 20:11 SebiGo

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.

stale[bot] avatar Apr 26 '23 10:04 stale[bot]

I am also interested in in this.

fyrak1s avatar May 09 '23 12:05 fyrak1s

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.

jackspiece avatar Jun 01 '26 15:06 jackspiece

This is released in [email protected]

martinjagodic avatar Jun 08 '26 08:06 martinjagodic