Ignoring repositories
This commit is contained in:
parent
0ee35feeb1
commit
3f84eaf185
4 changed files with 26 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|||
### Added
|
||||
|
||||
- Set a default `depth` in config.yaml and remove the hard-coded value.
|
||||
- Ignore repository paths using `ignores` in config.yaml.
|
||||
|
||||
## [0.1.0]
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
1
todo.txt
1
todo.txt
|
|
@ -2,6 +2,7 @@
|
|||
* Update the repositories within each directory.
|
||||
* Make depth configurable per directory.
|
||||
* Set a default depth in config.yaml.
|
||||
* Add excluding/ignoring a repository.
|
||||
|
||||
Add unit tests.
|
||||
Add a `--dry-run` option.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue