autotypist/simpleRelease.go

59 lines
1.3 KiB
Go
Raw Permalink Normal View History

package main
import (
"fmt"
"net/http"
"strings"
"go.wit.com/log"
)
// attempts a simple release
// merge user branch -> devel; then;
// git push
// merge devel branch -> master; then;
// git push
// increments the minor version by 1; then;
// git push --tags
func simpleRelease(w http.ResponseWriter, r *http.Request) {
repoName := r.URL.Query().Get("repo")
if repoName == "" {
log.Info("url did not have repo variable")
return
}
// git pull (or go-clone of it doesn't exist)
2024-11-22 21:04:56 -06:00
repo := me.repos.View.FindByName(repoName)
if repo == nil {
log.Info("repo unknown: " + repoName)
return
}
header := repo.StandardHeader()
if repo.CheckDirty() {
log.Info(header + "skip dirty repo")
return
}
if repo.State() == "PERFECT" {
log.Info(header + "already released")
return
}
curName := repo.Status.GetCurrentBranchName()
mName := repo.Status.GetMasterBranchName()
if curName != mName {
// s := log.Sprintf("\trepo is not working from main branch", curName, "!=", mName)
s := fmt.Sprint("repo is not working from main branch ", curName, " != ", mName)
log.Info(s)
return
}
cmd := []string{"git", "pull", "-v"}
log.Info(header + strings.Join(cmd, " "))
if repo.Status.MergeUserToDevel() {
log.Info("THINGS SEEM OK MergeUserToDevel() returned true.")
} else {
log.Info("THINGS FAILED MergeUserToDevel() returned false")
}
return
}