last of the easy rm old code

This commit is contained in:
Jeff Carr 2025-01-07 19:09:25 -06:00
parent 4dcd9a1164
commit 4efbead37c
3 changed files with 8 additions and 143 deletions

104
git.go
View File

@ -3,13 +3,13 @@ package repostatus
import (
"errors"
"strings"
"time"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
/*
func (rs *RepoStatus) GetCurrentBranchName() string {
return rs.currentBranch.String()
}
@ -18,12 +18,6 @@ func (rs *RepoStatus) GetCurrentBranchVersion() string {
return rs.currentVersion.String()
}
/*
func (rs *RepoStatus) LastGitPull() (time.Time, error) {
return rs.mtime(".git/FETCH_HEAD")
}
*/
func (rs *RepoStatus) Age() time.Duration {
var t *Tag
t = rs.NewestTag()
@ -41,37 +35,13 @@ func (rs *RepoStatus) Age() time.Duration {
var ErrorMissingGitConfig error = errors.New("missing .git/config")
var ErrorGitPullOnLocal error = errors.New("git pull on local only branch")
*/
// remove this everything
func (rs *RepoStatus) Path() string {
return rs.realPath.String()
}
/*
func (rs *RepoStatus) checkoutBranch(level string, branch string) {
if rs.CheckDirty() {
log.Log(REPO, "checkoutBranch() checkDirty() == true for repo", rs.realPath.String(), "looking for branch:", branch)
return
}
out := run(rs.realPath.String(), "git", "checkout "+branch)
log.Log(REPO, rs.realPath.String(), "git checkout "+branch, "returned", out)
realname := rs.GetCurrentBranchName()
realversion := rs.GetCurrentBranchVersion()
log.Log(REPO, rs.realPath.String(), "realname =", realname, "realversion =", realversion)
switch level {
case "master":
rs.mainBranchVersion.SetValue(realversion)
case "devel":
rs.develBranchVersion.SetValue(realversion)
case "user":
rs.userBranchVersion.SetValue(realversion)
default:
}
}
*/
func (rs *RepoStatus) GitState() string {
return rs.gitState.String()
}
@ -212,52 +182,11 @@ func (rs *RepoStatus) populateTags() {
// rs.tagsDrop.SetText(rs.lasttagrev)
}
/*
func (rs *RepoStatus) getBranches() []string {
var all []string
var heads []string
var remotes []string
heads = gitpb.ListFiles(rs.realPath.String() + "/.git/refs/heads")
remotes = gitpb.ListFiles(rs.realPath.String() + "/.git/refs/remotes")
all = heads
all = append(all, remotes...)
for _, branch := range all {
log.Log(REPO, "getBranches()", branch)
}
return all
}
*/
// returns quickly based on the last time it was checked
func (rs *RepoStatus) IsDirty() bool {
return rs.pb.IsDirty()
}
/*
// return the list of dirty files (but ignores go.mod & go.sum)
func (rs *RepoStatus) DirtyList() []string {
var all []string
for _, line := range strings.Split(rs.dirtyList, "\n") {
line = strings.TrimSpace(line)
parts := strings.Split(line, " ")
if len(parts) != 2 {
continue
}
if parts[1] == "go.mod" {
continue
}
if parts[1] == "go.sum" {
continue
}
all = append(all, parts[1])
}
return all
}
*/
func (rs *RepoStatus) CheckDirty() bool {
if rs.pb.IsDirty() {
rs.dirtyLabel.SetValue("dirty")
@ -266,32 +195,3 @@ func (rs *RepoStatus) CheckDirty() bool {
rs.dirtyLabel.SetValue("")
return false
}
/*
func (rs *RepoStatus) CheckoutBranch(bname string) bool {
if rs.CheckDirty() {
log.Log(REPO, rs.realPath.String(), "is dirty")
log.Info(bname, "is dirty", rs.Path())
return false
}
if !rs.TagExists(bname) {
// tag does not exist
log.Log(REPO, "repo does not have branch", bname, rs.Path())
return false
}
cName := rs.GetCurrentBranchName()
if cName == bname {
// already on branch
return true
}
cmd := []string{"git", "checkout", bname}
r := rs.Run(cmd)
if r.Error != nil {
log.Log(REPO, "git checkout error:", r.Error)
return false
}
rs.checkCurrentBranchName()
rs.checkCurrentBranchVersion()
return true
}
*/

View File

@ -171,7 +171,7 @@ func (rs *RepoStatus) readGitConfig() error {
}
log.Log(REPO, "error fetch mismatch", test.fetch, value)
default:
log.Log(REPO, "unknown remote:", rs.Path(), line)
log.Log(REPO, "unknown remote:", line)
}
case "branch":
test, ok := rs.gitConfig.branches[currentName]
@ -187,7 +187,7 @@ func (rs *RepoStatus) readGitConfig() error {
rs.gitConfig.branches[currentName].merge = value
default:
log.Log(REPO, "error unknown remote:", currentSection, currentName, key, value)
log.Log(REPO, "unknown branch:", rs.Path(), line)
log.Log(REPO, "unknown branch:", line)
}
case "submodule":
// test, ok := rs.gitConfig.submodules[currentName]
@ -197,10 +197,10 @@ func (rs *RepoStatus) readGitConfig() error {
case "url":
rs.gitConfig.submodules[currentName] = value
default:
log.Log(REPOWARN, "unknown submodule line:", rs.Path(), line)
log.Log(REPOWARN, "unknown submodule line:", line)
}
default:
log.Log(REPOWARN, "unknown line:", rs.Path(), line)
log.Log(REPOWARN, "unknown line:", line)
}
}
@ -261,7 +261,7 @@ func (rs *RepoStatus) processBranch(branch string) {
data, err := ioutil.ReadFile(filename)
if err != nil {
log.Log(WARN, "hash: read failed", filename, rs.Path())
log.Log(WARN, "hash: read failed", filename)
return
}
newhash := strings.TrimSpace(string(data))
@ -269,7 +269,7 @@ func (rs *RepoStatus) processBranch(branch string) {
rs.gitConfig.hashes[branch] = newhash
if ok {
if hash != newhash {
log.Log(WARN, "hash changed", hash, rs.Path())
log.Log(WARN, "hash changed", hash)
}
}

35
unix.go
View File

@ -1,35 +0,0 @@
package repostatus
/*
func (rs *RepoStatus) XtermNohup(cmdline string) {
shell.XtermCmd(rs.Path(), []string{cmdline})
}
func (rs *RepoStatus) Xterm(cmdline string) {
shell.XtermCmd(rs.Path(), []string{cmdline})
}
func (rs *RepoStatus) XtermWait(cmdline string) {
shell.XtermCmdWait(rs.Path(), []string{cmdline})
}
func (rs *RepoStatus) XtermBash(args []string) {
var argsX = []string{"-geometry", "120x40"}
tmp := strings.Join(args, " ") + ";bash"
argsX = append(argsX, "-e", "bash", "-c", tmp)
argsX = append(argsX, args...)
log.Info("xterm cmd=", argsX)
// set less to not exit on small diff's
os.Setenv("LESS", "-+F -+X -R")
cmd := exec.Command("xterm", argsX...)
path := rs.realPath.String()
cmd.Dir = path
if err := cmd.Run(); err != nil {
log.Log(WARN, "xterm.Run() failed")
log.Log(WARN, "path =", path)
log.Log(WARN, "cmd = xterm", argsX)
} else {
log.Log(WARN, "xterm.Run() worked")
log.Log(WARN, "path =", path)
log.Log(WARN, "cmd = xterm", argsX)
}
}
*/