Ignoring repositories

This commit is contained in:
Oliver Davies 2025-07-31 22:57:02 +01:00
parent 0ee35feeb1
commit 3f84eaf185
4 changed files with 26 additions and 1 deletions

View file

@ -11,6 +11,7 @@ import (
type Config struct {
Depth string `yaml:"depth"`
Directories []string `yaml:"directories"`
IgnoredRepos []string `yaml:"ignored"`
}
func getConfigPath() (string, error) {

View file

@ -4,13 +4,35 @@ import (
"fmt"
"os"
"os/exec"
"slices"
"strings"
"git-repo-updater/internal/config"
"git-repo-updater/internal/utils"
)
func Update(repositoryPath string) error {
cfg, err := config.Load()
if err != nil {
}
repositoryPath = strings.TrimSuffix(repositoryPath, "/.git")
err := os.Chdir(repositoryPath)
expandedIgnored := make([]string, 0, len(cfg.IgnoredRepos))
for _, ignored := range cfg.IgnoredRepos {
if expanded, err := utils.ExpandPath(ignored); err == nil {
expandedIgnored = append(expandedIgnored, expanded)
}
}
if slices.Contains(expandedIgnored, repositoryPath) {
fmt.Printf("Skipping %s as it's ignored\n", repositoryPath)
return nil
}
err = os.Chdir(repositoryPath)
if err != nil {
return fmt.Errorf("failed to change directory to %s: %w", repositoryPath, err)