summaryrefslogtreecommitdiff
path: root/changed.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-17 20:48:23 -0600
committerJeff Carr <[email protected]>2024-12-17 20:48:23 -0600
commitbea54091d2901d00c03541be09f33ae29e72cde1 (patch)
tree8d7e1257b88202532d59de35fd4d71a43c837544 /changed.go
parent10cc012a125e80ffb95dbc28c99d443e4427a0ba (diff)
try to fix Current branch and version
Diffstat (limited to 'changed.go')
-rw-r--r--changed.go110
1 files changed, 0 insertions, 110 deletions
diff --git a/changed.go b/changed.go
deleted file mode 100644
index 4d6fed4..0000000
--- a/changed.go
+++ /dev/null
@@ -1,110 +0,0 @@
-package gitpb
-
-// An app to submit patches for the 30 GO GUI repos
-
-import (
- "fmt"
- "time"
-
- "go.wit.com/lib/gui/shell"
- "go.wit.com/log"
- "google.golang.org/protobuf/types/known/timestamppb"
-)
-
-func (repo *Repo) Mtime(fname string) *time.Time {
- var fileTime *time.Time
- tmp, err := repo.oldMtime(fname)
- fileTime = &tmp
- if err != nil {
- log.Info("MTime got err", err)
- return nil
- }
- return fileTime
-}
-
-func (repo *Repo) changedDir() bool {
- fname := ".git"
- fileTime := repo.Mtime(fname)
- if fileTime == nil {
- // .git doesn't exist. something is wrong. rescan this repo
- return true
- }
- mtime := timestamppb.New(*fileTime)
- pbtime := repo.Times.MtimeDir
- if pbtime == nil { // this can happen?
- repo.Times.MtimeDir = mtime
- return true
- }
- if (pbtime.Seconds == mtime.Seconds) && (pbtime.Nanos == mtime.Nanos) {
- return false
- }
- dur := mtime.AsTime().Sub(pbtime.AsTime())
- repo.StateChange = fmt.Sprintf("%s changed %s", fname, shell.FormatDuration(dur))
- repo.Times.MtimeDir = mtime
- return true
-}
-
-func (repo *Repo) changedHead() bool {
- fname := ".git/HEAD"
- fileTime := repo.Mtime(fname)
- if fileTime == nil {
- // .git/HEAD doesn't exist. something is wrong. rescan this repo
- return true
- }
- mtime := timestamppb.New(*fileTime)
- pbtime := repo.Times.MtimeHead
- if pbtime == nil { // this can happen?
- repo.Times.MtimeHead = mtime
- return true
- }
-
- if (pbtime.Seconds == mtime.Seconds) && (pbtime.Nanos == mtime.Nanos) {
- return false
- }
- dur := mtime.AsTime().Sub(pbtime.AsTime())
- repo.StateChange = fmt.Sprintf("%s changed %s", fname, shell.FormatDuration(dur))
- repo.Times.MtimeHead = mtime
- return true
-}
-
-func (repo *Repo) changedIndex() bool {
- fname := ".git/index"
- fileTime := repo.Mtime(fname)
- if fileTime == nil {
- // .git/index doesn't exist. something is wrong. rescan this repo
- return true
- }
- mtime := timestamppb.New(*fileTime)
- pbtime := repo.Times.MtimeIndex
- if pbtime == nil { // this can happen?
- repo.Times.MtimeIndex = mtime
- return true
- }
- if (pbtime.Seconds == mtime.Seconds) && (pbtime.Nanos == mtime.Nanos) {
- return false
- }
- dur := mtime.AsTime().Sub(pbtime.AsTime())
- repo.StateChange = fmt.Sprintf("%s changed %s", fname, shell.FormatDuration(dur))
- repo.Times.MtimeIndex = mtime
- return true
-}
-
-func (repo *Repo) RepoChanged() bool {
- var changed bool
- if repo.Times == nil {
- repo.Times = new(GitTimes)
- log.Info(repo.FullPath, "repo.Times were nil")
- }
-
- if repo.changedHead() {
- changed = true
- }
- if repo.changedIndex() {
- changed = true
- }
- if repo.changedDir() {
- // changed = true
- }
-
- return changed
-}