Revert "feat: checkout the repository worktree with go-git instead of invoking the git command"

revert for now as the actual git command line is way more robust than go git and this new code immediately failed on the first repository i tested it on, gating it behind an option might make sense though for container applications

This reverts commit e59a558dcd.
This commit is contained in:
maia arson crimew 2024-03-05 21:05:55 +01:00
parent e59a558dcd
commit 3c15d60c83
1 changed files with 4 additions and 18 deletions

View File

@ -8,6 +8,7 @@ import (
"io/ioutil"
"net/url"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
@ -16,7 +17,6 @@ import (
"github.com/deletescape/goop/internal/workers"
"github.com/deletescape/jobtracker"
"github.com/go-git/go-billy/v5/osfs"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/cache"
"github.com/go-git/go-git/v5/plumbing/format/commitgraph"
@ -425,23 +425,9 @@ func FetchGit(baseUrl, baseDir string) error {
func checkout(baseDir string) error {
log.Info().Str("dir", baseDir).Msg("running git checkout .")
log.Info().Str("dir", baseDir).Msg("opening the current repository")
repo, err := git.PlainOpen(baseDir)
if err != nil {
return err
}
log.Info().Str("dir", baseDir).Msg("switching to repo worktree")
worktree, err := repo.Worktree()
if err != nil {
return err
}
log.Info().Str("dir", baseDir).Msg("checking out current worktree")
return worktree.Checkout(&git.CheckoutOptions{})
cmd := exec.Command("git", "checkout", ".")
cmd.Dir = baseDir
return cmd.Run()
}
func fetchLfs(baseDir, baseUrl string) {