raw gitpb Repo() scan

This commit is contained in:
Jeff Carr 2025-09-11 14:21:09 -05:00
parent fd199a4404
commit b05b706d8b
6 changed files with 28 additions and 50 deletions

View File

@ -4,10 +4,9 @@ VERSION = $(shell git describe --tags)
DATE = $(shell date +%Y.%m.%d)
run: clean goimports vet install
go-deb --release --forge go.wit.com/apps/autogenpb --dir /tmp/
go-deb --release --forge go.wit.com/apps/go-mod-clean --dir /tmp/
@#go-deb --forge go.wit.com/apps/autotypist
ls -lth /tmp/*deb
#go-deb --release go.wit.com/apps/go-mod-clean --dir /tmp/
#go-deb go.wit.com/apps/autotypist
#ls -lth /tmp/*deb
vet:
@GO111MODULE=off go vet
@ -66,3 +65,6 @@ build-release:
debian: build
./go-deb --keep-files --repo go.wit.com/apps/go-deb
test2:
go-deb go.wit.com/apps/utils/go-gui-toolkits --dir /tmp

View File

@ -16,7 +16,6 @@ type args struct {
Show *EmptyCmd `arg:"subcommand:show" help:"show what would be done"`
Gui *EmptyCmd `arg:"subcommand:gui" help:"open the gui"`
Ldflags []string `arg:"--ldflags" help:"flags to pass to go build"`
Forge string `arg:"--forge" help:"use a git repo from forge"`
OutDir string `arg:"--dir" help:"write .deb file into this directory"`
Release bool `arg:"--release" help:"build a release from the last git tag"`
KeepFiles bool `arg:"--keep-files" help:"keep the build files/"`

View File

@ -65,41 +65,33 @@ func buildPackage(c *controlBox) (bool, error) {
return false, errors.New("binary existed before build")
}
/*
forgecmd := "forge"
if argv.Forge == "go.wit.com/apps/forge" {
forgecmd = "last.forge"
}
*/
if argv.Release {
os.Unsetenv("GO111MODULE")
// cmd := []string{forgecmd, "--verbose", "--install", argv.Forge}
cmd := []string{"go"}
cmd = append(cmd, "install")
if argv.Verbose {
cmd = append(cmd, "-v")
cmd = append(cmd, "-x")
}
cmd = append(cmd, argv.Forge+"@v"+version)
if err := shell.PathExecVerbose("", cmd); err != nil {
badExit(err)
return false, fmt.Errorf("go build err %v", err)
}
// must 'go install' then 'go build' so they are both in ~/go/src and in the repo dir
// cmd = []string{forgecmd, "--verbose", "--build", argv.Forge}
/*
cmd = append(cmd, "some path"+"@v"+version)
if err := shell.PathExecVerbose("", cmd); err != nil {
badExit(err)
return false, fmt.Errorf("go build err %v", err)
}
*/
cmd = []string{"go"}
cmd = append(cmd, "build")
if argv.Verbose {
cmd = append(cmd, "-v")
cmd = append(cmd, "-x")
}
cmd = append(cmd, argv.Forge)
cmd = append(cmd, "this should be the path")
if err := shell.PathExecVerbose("", cmd); err != nil {
badExit(err)
return false, fmt.Errorf("go build err %v", err)
}
log.Warn("forge build worked")
log.Warn("build worked")
} else {
// set the GO111 build var to true. pass the versions to the compiler manually
os.Setenv("GO111MODULE", "off")
@ -335,5 +327,5 @@ func (c *controlBox) getDateStamp(tag string) string {
// Parse the Unix timestamp into a time.Time object
gitTagDate := time.Unix(gitTagTimestampInt, 0)
return gitTagDate.UTC().Format("2006-01-02_15:04:05_UTC") // same format used in forge. close to RFC3339
return gitTagDate.UTC().Format("2006-01-02_15:04:05_UTC") // close to RFC3339
}

View File

@ -7,7 +7,9 @@ import (
)
func okExit(thing string) {
log.Info(thing, "ok")
if thing != "" {
log.Info(thing, "ok")
}
// log.Info("Finished go-clean on", check.GetGoPath(), "ok")
os.Exit(0)
}

33
main.go
View File

@ -7,9 +7,8 @@ import (
"time"
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/fhelp"
"go.wit.com/lib/gui/prep"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
@ -29,37 +28,23 @@ func main() {
me.myGui = prep.Gui() // prepares the GUI package for go-args
me.pp = arg.MustParse(&argv)
if err := fhelp.ConfigureENV(); err != nil {
wd, err := os.Getwd()
if err != nil {
badExit(err)
}
me.goSrc = os.Getenv("FORGE_GOSRC")
if os.Getenv("FORGE_GOWORK") == "true" {
me.hasWork = true
me.repo, err = gitpb.NewRepo(wd)
if err != nil {
badExit(err)
}
log.Info("GO src path", me.goSrc, "go.work is", me.hasWork)
// set the go src path
os.Setenv("REPO_WORK_PATH", me.goSrc)
if argv.Forge != "" {
me.forge = forgepb.Init()
me.repo = me.forge.Repos.FindByFullPath(argv.Forge)
if me.repo == nil {
log.Info("repo not found", argv.Forge)
me.repo = me.forge.FindByGoPath(argv.Forge)
}
if me.repo == nil {
log.Info("forge failure. repo not found", argv.Forge)
os.Exit(-1)
}
log.Info("found repo", me.repo.GetGoPath())
}
// build()
if argv.Show != nil {
log.Info("todo: show", me.repo.GetGoPath())
okExit("")
}
log.Info("todo: show", me.repo.GetNamespace(), me.repo.GetFullPath())
okExit("")
me.basicWindow = makebasicWindow()

View File

@ -4,7 +4,6 @@ import (
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/prep"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
)
@ -16,7 +15,6 @@ type mainType struct {
goSrc string // path to ~/go/src or go.work file
goPath string // the goPath to use for the package
hasWork bool // true if using go.work file
forge *forgepb.Forge // the interface to the 'forge' protobuf information
repo *gitpb.Repo // this is the repo we are in
myGui *prep.GuiPrep // the gui toolkit handle
cBox *controlBox // the GUI box in the main window