add delete tag
This commit is contained in:
parent
7c520aae88
commit
b5df8f2dad
39
doTag.go
39
doTag.go
|
@ -6,18 +6,57 @@ package main
|
||||||
// checks that repos are in a "normal" state
|
// checks that repos are in a "normal" state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.wit.com/lib/fhelp"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/log"
|
"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 {
|
func doTag() error {
|
||||||
if argv.Tag.List != nil {
|
if argv.Tag.List != nil {
|
||||||
log.Info("list tags here")
|
log.Info("list tags here")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if argv.Tag.Delete != "" {
|
||||||
|
wd, _ := os.Getwd()
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
ns := "go.wit.com/apps/forge"
|
ns := "go.wit.com/apps/forge"
|
||||||
repo := me.forge.Repos.FindByNamespace(ns)
|
repo := me.forge.Repos.FindByNamespace(ns)
|
||||||
if repo == nil {
|
if repo == nil {
|
||||||
|
|
Loading…
Reference in New Issue