-
Notifications
You must be signed in to change notification settings - Fork 6
Investigate if it's possible to add GitLFS support to go-git #262
Comments
It seems that package main
import (
"fmt"
"github.com/git-lfs/git-lfs/v3/config"
"github.com/git-lfs/git-lfs/v3/lfs"
"github.com/go-git/go-git/v5"
"os"
)
func main() {
if err := lfsScan(); err != nil {
panic(err)
}
}
func lfsScan() error {
dir, err := os.MkdirTemp("", "")
if err != nil {
return err
}
if err := os.Chdir(dir); err != nil {
return err
}
repo, err := git.PlainClone(dir, false, &git.CloneOptions{
URL: "https://github.com/devopswise/git-lfs-sample.git",
})
if err != nil {
return err
}
head, err := repo.Head()
if err != nil {
return err
}
cfg := config.NewIn(dir, dir)
scanner := lfs.NewGitScanner(cfg, func(p *lfs.WrappedPointer, err error) {
fmt.Println(p, err)
})
defer scanner.Close()
if err := scanner.ScanTree(head.Hash().String(), nil); err != nil {
return err
}
return nil
} But if we comment the: if err := os.Chdir(dir); err != nil {
return err
} We will get the following error:
This comes from Perhaps we could implement a lightweight library based on the spec + API spec. |
Thank you for the investigation! In that case I started thinking of making the |
You mean we should use built-in |
It will be nice to have Git LFS support as part of the built-in Git client that the agent has. Unfortunately, there is no such support out of the box and Git LFS itself encourages not to source depend on it.
But it seems worth investigating if the integration is that hard and if APIs that the integration need are changing that often as Git LFS claims in limitations.
The text was updated successfully, but these errors were encountered: