Changed strategie to git rm -r as suggested by earl-warren

This commit is contained in:
David Rotermund 2025-05-16 21:01:07 +02:00
parent 4ac8628d2a
commit f6c20e9886
4 changed files with 106 additions and 45 deletions

View file

@ -6,7 +6,6 @@ package git
import (
"bytes"
"context"
"errors"
"os"
"path/filepath"
"strings"
@ -103,30 +102,6 @@ func (repo *Repository) LsFiles(filenames ...string) ([]string, error) {
return filelist, err
}
// Gives a list of all files in a directory and below
func (repo *Repository) LsFilesFromDirectory(directory, branch string) ([]string, error) {
if branch == "" {
return nil, errors.New("branch not found in context URL")
}
cmd := NewCommand(repo.Ctx, "ls-files").AddOptionFormat("--with-tree=%s", branch)
if len(directory) > 0 {
cmd.AddArguments("--directory").AddDashesAndList(directory)
}
res, stderror, err := cmd.RunStdBytes(&RunOpts{Dir: repo.Path})
if err != nil {
return nil, err
}
if len(stderror) > 0 {
return nil, errors.New(string(stderror))
}
lines := strings.Split(string(res), "\n")
return lines, nil
}
// RemoveFilesFromIndex removes given filenames from the index - it does not check whether they are present.
func (repo *Repository) RemoveFilesFromIndex(filenames ...string) error {
objectFormat, err := repo.GetObjectFormat()