Compare commits

..

No commits in common. "main" and "0.1.0" have entirely different histories.
main ... 0.1.0

16 changed files with 10 additions and 153 deletions

View file

@ -1,7 +0,0 @@
on: push
jobs:
check:
runs-on: nixos
steps:
- uses: actions/checkout@v4
- run: nix develop -c just test

2
.gitignore vendored
View file

@ -1,2 +0,0 @@
/git-repo-updater
/result

View file

@ -6,26 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
## [Unreleased]
Nothing yet.
## [0.2.0] (2025-08-05)
### Added
- Set a default `depth` in config.yaml and remove the hard-coded value.
- Ignore repository paths using `ignores` in config.yaml.
## Changed
- Update module paths to my Forgejo instance (`code.oliverdavies.uk`).
## [0.1.0] (2025-07-31)
### Added
- Load a list of directories from a configuration file (`~/.config/git-repo-updater/config.yaml`).
- Configure the depth to search in each directory by appending it to the path - e.g. (`~/Code:3`).
[unreleased]: https://code.oliverdavies.uk/opdavies/git-repo-updater/compare/0.2.0...main
[0.2.0]: https://code.oliverdavies.uk/opdavies/git-repo-updater/compare/0.1.0...0.2.0
[0.1.0]: https://code.oliverdavies.uk/opdavies/git-repo-updater/releases/tag/0.1.0
[unreleased]: https://code.oliverdavies.uk/opdavies/git-repo-updater/commits/branch/main

View file

@ -1,23 +0,0 @@
# git-repo-updater
`git-repo-updater` is an CLI program that finds and updates Git repositories in specified directories.
## Configuration
`git-repo-updater` is configurable using a configuration file at `~/.config/git-repo-updater/config.yaml`.
For example:
```yaml
# The number of levels to search.
depth: 3
# A list of directories to search in.
directories:
- ~/Code/code.oliverdavies.uk
- ~/Code/github.com
# A list of repositories to ignore and not update.
ignored:
- ~/Code/github.com/nixos/nixpkgs
```

View file

@ -1,13 +0,0 @@
# The default depth in each directory to search for Git repositories.
depth: 2
# A list of directories to search in.
directories:
- ~/Code/forgejo:3
- ~/Code/github:3
# A list of repository paths to ignore (not update).
ignored:
- ~/Code/github/nixos/nixpkgs
# vim: ft=yaml

View file

@ -12,7 +12,6 @@
packages = with pkgs; [
go
gopls
just
];
};
};

View file

@ -1,11 +0,0 @@
{
perSystem =
{ pkgs, ... }:
{
packages.default = pkgs.buildGoModule {
name = "git-repo-updater";
src = ../.;
vendorHash = "sha256-g+yaVIx4jxpAQ/+WrGKxhVeliYx7nLQe/zsGpxV4Fn4=";
};
};
}

4
go.mod
View file

@ -1,5 +1,5 @@
module code.oliverdavies.uk/opdavies/git-repo-updater
module git-repo-updater
go 1.24.5
require gopkg.in/yaml.v3 v3.0.1
require gopkg.in/yaml.v3 v3.0.1 // indirect

1
go.sum
View file

@ -1,4 +1,3 @@
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View file

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

View file

@ -6,8 +6,7 @@ import (
"os/exec"
"strings"
"code.oliverdavies.uk/opdavies/git-repo-updater/internal/config"
"code.oliverdavies.uk/opdavies/git-repo-updater/internal/utils"
"git-repo-updater/internal/utils"
)
func FindInDirectory(dir string) (string, error) {
@ -37,16 +36,10 @@ func FindInDirectory(dir string) (string, error) {
}
func splitPath(repoPath string) (string, string) {
cfg, err := config.Load()
if err != nil {
// TODO
}
parts := strings.SplitN(repoPath, ":", 2)
repoPath = parts[0]
depth := cfg.Depth
depth := "2"
if len(parts) == 2 {
return parts[0], parts[1]

View file

@ -4,36 +4,13 @@ import (
"fmt"
"os"
"os/exec"
"slices"
"strings"
"code.oliverdavies.uk/opdavies/git-repo-updater/internal/config"
"code.oliverdavies.uk/opdavies/git-repo-updater/internal/utils"
)
func Update(repositoryPath string) error {
cfg, err := config.Load()
if err != nil {
// TODO
}
repositoryPath = strings.TrimSuffix(repositoryPath, "/.git")
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)
err := os.Chdir(repositoryPath)
if err != nil {
return fmt.Errorf("failed to change directory to %s: %w", repositoryPath, err)

View file

@ -1,26 +0,0 @@
package utils_test
import (
"os"
"path/filepath"
"testing"
"code.oliverdavies.uk/opdavies/git-repo-updater/internal/utils"
)
func TestExpandPath(t *testing.T) {
home, _ := os.UserHomeDir()
input := "~/Code/my-repo"
expected := filepath.Join(home, "Code/my-repo")
result, err := utils.ExpandPath(input)
if err != nil {
t.Errorf("ExpandPath(%q) returned error: %v", input, err)
}
if result != expected {
t.Errorf("ExpandPath(%q) = %q; want %q", input, result, expected)
}
}

View file

@ -1,5 +0,0 @@
@default:
just --list
test:
go test ./... -v

View file

@ -4,8 +4,8 @@ import (
"log"
"strings"
"code.oliverdavies.uk/opdavies/git-repo-updater/internal/config"
"code.oliverdavies.uk/opdavies/git-repo-updater/internal/repositories"
"git-repo-updater/internal/config"
"git-repo-updater/internal/repositories"
)
func main() {

View file

@ -1,13 +1,9 @@
* Load directories from a configuration file
* Update the repositories within each directory.
* Make depth configurable per directory.
* Set a default depth in config.yaml.
* Add excluding/ignoring a repository.
* Add Nix package.
Set a default depth in config.yaml.
Add unit tests.
Add a `--dry-run` option.
Complete README.
Filtering repos by path at runtime?
grep -r --exclude-dir=.git TODO .
Add Nix package.