Borg/cmd/helpers.go
google-labs-jules[bot] 21f9a9ca74 feat: Implement core data collection and Trix cube functionality
This commit introduces the core functionality of the Borg Data Collector.

- Adds the `collect` command to clone a single Git repository and store it in a Trix cube.
- Adds the `collect all` command to clone all public repositories from a GitHub user or organization.
- Implements the Trix cube as a `tar` archive.
- Adds the `ingest` command to add files to a Trix cube.
- Adds the `cat` command to extract files from a Trix cube.
- Integrates Borg-themed status messages for a more engaging user experience.
2025-10-31 05:02:29 +00:00

41 lines
715 B
Go

package cmd
import (
"os"
"path/filepath"
"borg-data-collector/pkg/trix"
"github.com/go-git/go-git/v5"
)
func addRepoToCube(repoURL string, cube *trix.Cube, clonePath string) error {
_, err := git.PlainClone(clonePath, false, &git.CloneOptions{
URL: repoURL,
Progress: os.Stdout,
})
if err != nil {
return err
}
err = filepath.Walk(clonePath, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
content, err := os.ReadFile(path)
if err != nil {
return err
}
relPath, err := filepath.Rel(clonePath, path)
if err != nil {
return err
}
cube.AddFile(relPath, content)
}
return nil
})
return err
}