From c521620b04473a5a5b3cea826b21d73fed2d2d20 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 22 Feb 2025 06:52:50 -0600 Subject: [PATCH] fix build and cleanup old code --- .gitignore | 2 +- Makefile | 18 ++++++++++++------ argv.go | 17 +++++------------ gitPull.go | 30 ------------------------------ main.go | 5 ----- 5 files changed, 18 insertions(+), 54 deletions(-) delete mode 100644 gitPull.go diff --git a/.gitignore b/.gitignore index b38b406..f2e24e3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ go.mod go.sum /files/* /work/* -go-clone +go-clone* diff --git a/Makefile b/Makefile index b3122f9..6809995 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,14 @@ VERSION = $(shell git describe --tags) BUILDTIME = $(shell date +%Y.%m.%d_%H%M) -run: build - ./go-clone --version +run: install build-darwin build-darwin-arm64 build-windows + go-clone --version vet: @GO111MODULE=off go vet @echo this go binary package builds okay -no-gui: build +no-gui: install build-darwin build-windows ./go-clone --no-gui build: goimports @@ -16,11 +16,16 @@ build: goimports -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" build-darwin: - GOOS=darwin GOARCH=amd64 GO111MODULE=off go build -v -o go-clone-darwin \ + GOOS=darwin GOARCH=amd64 GO111MODULE=off go build -v -o go-clone-darwin.x86 \ -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" + +build-darwin-arm64: + GOOS=darwin GOARCH=arm64 GO111MODULE=off go build -v -o go-clone-darwin.arm \ + -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" + build-windows: - GOOS=windows GOARCH=amd64 GO111MODULE=off go build -v go-clone.exe \ - -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" + GOOS=windows GOARCH=amd64 GO111MODULE=off go build -v -o go-clone.exe \ + -ldflags "-X main.VERSION=v0.7.46 -X main.BUILDTIME=2025.02.22_0643 -X gui.GUIVERSION=v0.7.46" install: goimports GO111MODULE=off go install \ @@ -45,6 +50,7 @@ nocui: build ./go-clone --gui nocui clean: + rm -f go.* -rm go-clone # this will test the golang.org/x -> googlesource override diff --git a/argv.go b/argv.go index f2abb8b..158aa23 100644 --- a/argv.go +++ b/argv.go @@ -12,10 +12,9 @@ type args struct { Repo string `arg:"positional" help:"go import path"` AutoWork bool `arg:"--work" default:"false" help:"recreate the go.work file"` DryRun bool `arg:"--dry-run" help:"show what would be run"` - Recursive bool `arg:"--recursive" default:"false" help:"recursively clone all dependencies"` - Pull bool `arg:"--git-pull" default:"false" help:"run 'git pull'"` - Build bool `arg:"--build" default:"true" help:"try to build it after clone"` - Install bool `arg:"--install" default:"false" help:"try to install it after clone"` + Recursive bool `arg:"--recursive" default:"true" help:"recursively clone all dependencies"` + Build bool `arg:"--build" help:"try to build it after clone"` + Install bool `arg:"--install" help:"try to install it after clone"` Ignore bool `arg:"--ignore" default:"false" help:"ignore weird clone errors from non-standard repos"` // Fetch bool `arg:"--git-fetch" default:"false" help:"run 'git fetch' on all your repos"` } @@ -26,15 +25,9 @@ func (args) Version() string { func (a args) Description() string { return ` -git clone go repositories +git clone go repositories recursively Examples: - go-clone go.wit.com/apps/go-clone # simply try to git clone this - go-clone --recursive go.wit.com/apps/go-clone # recursively clone all the dependencies - go-clone --auto-work go.wit.com/apps/go-clone # if you are using a go.work file, recreate the go.work file - go-clone --go-reset # recreate every go.mod and go.sum file - go-clone --git-pull # run 'git pull' in every repo - go-clone --build # build every binary package - go-clone --install # install every binary package + go-clone go.wit.com/apps/go-clone # 'git clone' go-clone ` } diff --git a/gitPull.go b/gitPull.go deleted file mode 100644 index f2e4528..0000000 --- a/gitPull.go +++ /dev/null @@ -1,30 +0,0 @@ -package main - -import ( - "go.wit.com/lib/gui/shell" - "go.wit.com/log" -) - -func gitPull() { - log.Info("Total repositories:", forge.Repos.Len()) - log.Info("Going to run git pull in each one. TODO: use rill here") - pull := []string{"git", "pull"} - - var trycount, errcount int - repos := forge.Repos.SortByFullPath() - for repos.Scan() { - repo := repos.Next() - if argv.DryRun { - log.Info("git pull --dry-run", repo.GetGoPath()) - continue - } - log.Info("git pull:", repo.FullPath) - trycount += 1 - log.Info("actually run: git pull:", repo.GetGoPath()) - if result := shell.PathRunRealtime(repo.FullPath, pull); result.Error != nil { - log.Info("git pull error:", result.Error) - errcount += 1 - } - } - log.Info("Total repositories:", forge.Repos.Len(), "Total attempted:", trycount, "Errors:", errcount) -} diff --git a/main.go b/main.go index d263e7f..1c9d310 100644 --- a/main.go +++ b/main.go @@ -77,11 +77,6 @@ func main() { badExit(err) } } - - if argv.Pull { - // run 'git pull' if argv --git-pull - gitPull() - } okExit("") }