fix build command
2 files changed, 17 insertions(+), 4 deletions(-)
M cmd/build/main.go → cmd/build/main.go
@@ -6,11 +6,14 @@ "os" "go.alanpearce.eu/website/internal/builder" "go.alanpearce.eu/website/internal/config" + "go.alanpearce.eu/website/internal/vcs" "go.alanpearce.eu/x/log" "github.com/ardanlabs/conf/v3" "gitlab.com/tozd/go/errors" ) + +const branch = "main" func main() { builderOptions := &builder.Options{}@@ -22,6 +25,15 @@ } panic("error parsing configuration: " + err.Error()) } log := log.Configure(!builderOptions.Development) + repo, _, err := vcs.CloneOrOpen(&vcs.Options{ + LocalPath: builderOptions.Source, + RemoteURL: builderOptions.VCSRemoteURL, + Branch: branch, + }, log.Named("vcs")) + if err != nil { + panic("could not open repository: " + err.Error()) + } + builderOptions.Repo = repo log.Debug("starting build process") cfg, err := config.GetConfig(builderOptions.Source, log)
M internal/builder/builder.go → internal/builder/builder.go
@@ -25,10 +25,11 @@ "gitlab.com/tozd/go/errors" ) type Options struct { - Source string `conf:"default:.,short:s,flag:src"` - Destination string `conf:"default:public,short:d,flag:dest"` - Development bool `conf:"default:false,flag:dev"` - Repo *vcs.Repository `conf:"-"` + Source string `conf:"default:.,short:s,flag:src"` + Destination string `conf:"default:public,short:d,flag:dest"` + Development bool `conf:"default:false,flag:dev"` + VCSRemoteURL config.URL `conf:"default:https://git.alanpearce.eu/website"` + Repo *vcs.Repository `conf:"-"` } type Result struct {