summaryrefslogtreecommitdiff
path: root/humanShowRepo.go
blob: d55b7c8a01726d12f69921f340cc64f17d94137f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package forgepb

import (
	"os"
	"path/filepath"
	"time"

	"go.wit.com/lib/gui/shell"
	"go.wit.com/lib/protobuf/gitpb"
	"go.wit.com/log"
)

func (f *Forge) HumanPrintRepo(check *gitpb.Repo) {
	if check == nil {
		log.Info("forge: you sent me nil")
		return
	}

	if check.GetTargetVersion() == "" {
		log.Info("TargetVersion == blank")
	}
	if check.GetTargetVersion() == check.GetCurrentVersion() {
		log.Info("IsReleased() == true. do not release this a second time")
	} else {
		log.Info("IsReleased() == false")
	}
	if check.CheckDirty() {
		log.Info("CheckDirty() == true.  do not release dirty repos")
	} else {
		log.Info("CheckDirty() == false")
	}
	if check.GetGoPrimitive() {
		log.Info("IsPrimitive() == true")
	} else {
		log.Info("IsPrimitive() == false")
	}
	if f.Config.IsPrivate(check.GetGoPath()) {
		log.Info("IsPrivate() == true")
	} else {
		log.Info("IsPrivate() == false")
	}
	if ok, compiled, err := check.IsProtobuf(); ok {
		log.Info(log.Sprint("IsProtobuf() == true compiled protobuf files = ", compiled))
		if err != nil {
			log.Info("IsProtobuf() ERROR = ", err)
		}
		for _, s := range compiled {
			log.Info("\tcompiled file found:", s)
		}
	} else {
		log.Info("IsProtobuf() == false")
		if err != nil {
			log.Info("IsProtobuf() ERROR = ", err)
		}
	}
	log.Info("git master  name ==", check.GetMasterBranchName())
	log.Info("git devel   name ==", check.GetDevelBranchName())
	log.Info("git user    name ==", check.GetUserBranchName())
	log.Info("git current name ==", check.GetCurrentBranchName())

	// testNext(check)

	found := new(gitpb.Repos)
	if !found.AppendByGoPath(check) {
		log.Info("forgepb check. repo already existed", check.FullPath, check.GetGoPath())
	} else {
		log.Info("forgepb check. repo was new", check.FullPath, check.GetGoPath())
	}
	f.PrintHumanTable(found)

	printTime("Last Pull", check.Times.LastPull.AsTime())
	printTime("Last Dirty", check.Times.LastDirty.AsTime())
	printTime("dir mtime", check.Times.MtimeDir.AsTime())
	printTime("HEAD mtime", check.Times.MtimeHead.AsTime())
	printTime("Index mtime", check.Times.MtimeIndex.AsTime())
	printTime("fetch", check.Times.MtimeFetch.AsTime())
	printTime("last go.sum", check.Times.LastGoDep.AsTime())
	printTime("last commit", check.Times.NewestCommit.AsTime())

	now := time.Now()
	dur := now.Sub(check.Times.LastUpdate.AsTime())
	log.Printf("Repo Last Reload: %s\n", shell.FormatDuration(dur))
}

func (f *Forge) testGoRepo(check *gitpb.Repo) {
	data, _ := os.ReadFile(filepath.Join(check.FullPath, "go.mod"))
	log.Info(string(data))

	if f.FinalGoDepsCheckOk(check, true) {
		log.Info("forge.FinalGoDepsCheck(check) worked!")
	} else {
		log.Info("forge.FinalGoDepsCheck(check) failed. boo.")
	}

}

func printTime(s string, t time.Time) {
	now := time.Now()
	dur := now.Sub(t)
	if dur < (time.Hour * 24) {
		log.Printf("%s mtime last changed %s\n", s, shell.FormatDuration(dur))
	}
}