admin: Create a GitImporter based on git binaries
This commit is contained in:
parent
23c43ad667
commit
43be59b97d
5 changed files with 133 additions and 35 deletions
|
|
@ -1,7 +1,9 @@
|
|||
//go:build gitgo
|
||||
// +build gitgo
|
||||
|
||||
package sync
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
|
@ -62,15 +64,6 @@ func (i GitImporter) Kind() string {
|
|||
return "git originated from " + i.Remote + " on " + i.li.Kind() + ", currently on commit " + gitinfo
|
||||
}
|
||||
|
||||
func countFileInDir(dirname string) (int, error) {
|
||||
files, err := os.ReadDir(dirname)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return len(files), nil
|
||||
}
|
||||
|
||||
func (i GitImporter) Init() error {
|
||||
// Check if the directory exists, create it if needed
|
||||
if err := i.li.Init(); err != nil {
|
||||
|
|
@ -130,27 +123,3 @@ func (i GitImporter) Sync() error {
|
|||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (i GitImporter) exists(filename string) bool {
|
||||
return i.li.exists(filename)
|
||||
}
|
||||
|
||||
func (i GitImporter) toURL(filename string) string {
|
||||
return i.li.toURL(filename)
|
||||
}
|
||||
|
||||
func (i GitImporter) importFile(URI string, next func(string, string) (interface{}, error)) (interface{}, error) {
|
||||
return i.li.importFile(URI, next)
|
||||
}
|
||||
|
||||
func (i GitImporter) getFile(filename string, writer *bufio.Writer) error {
|
||||
return i.li.getFile(filename, writer)
|
||||
}
|
||||
|
||||
func (i GitImporter) listDir(filename string) ([]string, error) {
|
||||
return i.li.listDir(filename)
|
||||
}
|
||||
|
||||
func (i GitImporter) stat(filename string) (os.FileInfo, error) {
|
||||
return i.li.stat(filename)
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue