// Copyright 2017-2025 WIT.COM Inc. All rights reserved. // Use of this source code is governed by the GPL 3.0 package main // checks that repos are in a "normal" state import ( "os" "path/filepath" "time" "go.wit.com/lib/fhelp" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) func FindRepoByFullPath(wd string) *gitpb.Repo { for repo := range me.forge.Repos.IterAll() { if repo.FullPath == wd { return repo } } return nil } func doTag() error { wd, _ := os.Getwd() if argv.Tag.List != nil { repo := FindRepoByFullPath(wd) if repo == nil { log.Info("Could not find repo:", wd) return nil } tagTablePB := makeTagTablePB(repo.Tags) // tbox := win.Bottom.Box().SetProgName("TBOX") // t.SetParent(tbox) tagTablePB.MakeTable() tagTablePB.PrintTable() log.Info("list tags here", repo.Namespace) return nil } if argv.Tag.Delete != "" { repo := FindRepoByFullPath(wd) if repo == nil { log.Info("Could not find repo:", wd) return nil } // check if the git tag already exists somehow testtag := argv.Tag.Delete if !repo.LocalTagExists(testtag) { log.Info("Tag", testtag, "does not exist") return log.Errorf("%s TAG DOES NOT EXIST %s", repo.FullPath, testtag) } if !argv.Force { if !fhelp.QuestionUser("delete this tag?") { return nil } } log.Info("Delete tag here", testtag) // delete local and remote tag repo.RunVerbose([]string{"git", "tag", "--delete", testtag}) repo.RunVerbose([]string{"git", "push", "--delete", "origin", testtag}) return nil } log.Info("do other tag stuff here") return nil } func makeTagTablePB(pb *gitpb.GitTags) *gitpb.GitTagsTable { t := pb.NewTable("tagList") t.NewUuid() col := t.AddHash() col.Width = 12 col = t.AddStringFunc("Ref Name", func(r *gitpb.GitTag) string { _, ref := filepath.Split(r.GetRefname()) return ref }) col.Width = 16 cola := t.AddTimeFunc("age", func(repo *gitpb.GitTag) time.Time { // todo return time.Now() }) cola.Width = 6 col = t.AddSubject() col.Width = -1 return t }