2024-11-04 03:23:28 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-11-04 05:44:32 -06:00
|
|
|
"fmt"
|
2024-11-04 03:23:28 -06:00
|
|
|
"net/http"
|
|
|
|
"strings"
|
2024-11-07 08:25:11 -06:00
|
|
|
|
|
|
|
"go.wit.com/log"
|
2024-11-04 03:23:28 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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 == "" {
|
2024-11-07 08:25:11 -06:00
|
|
|
log.Info("url did not have repo variable")
|
2024-11-04 03:23:28 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
// git pull (or go-clone of it doesn't exist)
|
|
|
|
repo := me.repos.View.FindRepoByName(repoName)
|
|
|
|
if repo == nil {
|
2024-11-07 08:25:11 -06:00
|
|
|
log.Info("repo unknown: " + repoName)
|
2024-11-04 03:23:28 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
header := repo.StandardHeader()
|
|
|
|
if repo.CheckDirty() {
|
2024-11-07 08:25:11 -06:00
|
|
|
log.Info(header + "skip dirty repo")
|
2024-11-04 05:44:32 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if repo.State() == "PERFECT" {
|
2024-11-07 08:25:11 -06:00
|
|
|
log.Info(header + "already released")
|
2024-11-04 05:44:32 -06:00
|
|
|
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)
|
2024-11-07 08:25:11 -06:00
|
|
|
log.Info(s)
|
2024-11-04 05:44:32 -06:00
|
|
|
return
|
2024-11-04 03:23:28 -06:00
|
|
|
}
|
|
|
|
cmd := []string{"git", "pull", "-v"}
|
2024-11-07 08:25:11 -06:00
|
|
|
log.Info(header + strings.Join(cmd, " "))
|
2024-11-04 05:44:32 -06:00
|
|
|
if repo.Status.MergeUserToDevel() {
|
2024-11-07 08:25:11 -06:00
|
|
|
log.Info("THINGS SEEM OK MergeUserToDevel() returned true.")
|
2024-11-04 05:44:32 -06:00
|
|
|
} else {
|
2024-11-07 08:25:11 -06:00
|
|
|
log.Info("THINGS FAILED MergeUserToDevel() returned false")
|
2024-11-04 05:44:32 -06:00
|
|
|
}
|
2024-11-04 03:23:28 -06:00
|
|
|
return
|
|
|
|
}
|