Ignoring repositories
This commit is contained in:
parent
0ee35feeb1
commit
3f84eaf185
4 changed files with 26 additions and 1 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
type Config struct {
|
||||
Depth string `yaml:"depth"`
|
||||
Directories []string `yaml:"directories"`
|
||||
IgnoredRepos []string `yaml:"ignored"`
|
||||
}
|
||||
|
||||
func getConfigPath() (string, error) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue