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
|
### Added
|
||||||
|
|
||||||
- Set a default `depth` in config.yaml and remove the hard-coded value.
|
- Set a default `depth` in config.yaml and remove the hard-coded value.
|
||||||
|
- Ignore repository paths using `ignores` in config.yaml.
|
||||||
|
|
||||||
## [0.1.0]
|
## [0.1.0]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import (
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Depth string `yaml:"depth"`
|
Depth string `yaml:"depth"`
|
||||||
Directories []string `yaml:"directories"`
|
Directories []string `yaml:"directories"`
|
||||||
|
IgnoredRepos []string `yaml:"ignored"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func getConfigPath() (string, error) {
|
func getConfigPath() (string, error) {
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,35 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"git-repo-updater/internal/config"
|
||||||
|
"git-repo-updater/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Update(repositoryPath string) error {
|
func Update(repositoryPath string) error {
|
||||||
|
cfg, err := config.Load()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
}
|
||||||
|
|
||||||
repositoryPath = strings.TrimSuffix(repositoryPath, "/.git")
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to change directory to %s: %w", repositoryPath, err)
|
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.
|
* Update the repositories within each directory.
|
||||||
* Make depth configurable per directory.
|
* Make depth configurable per directory.
|
||||||
* Set a default depth in config.yaml.
|
* Set a default depth in config.yaml.
|
||||||
|
* Add excluding/ignoring a repository.
|
||||||
|
|
||||||
Add unit tests.
|
Add unit tests.
|
||||||
Add a `--dry-run` option.
|
Add a `--dry-run` option.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue