summaryrefslogtreecommitdiff
path: root/reloadMtime.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-18 10:34:58 -0600
committerJeff Carr <[email protected]>2025-01-18 10:34:58 -0600
commit0c30a9da2f9a30a9f41c755879ea5be266180ce0 (patch)
tree6cea2ef505f0cb92db890fd6a10f55f22f860c05 /reloadMtime.go
parent80f602c4d91fa84cfbafd3787cf255d2832ed588 (diff)
parse .git/configv0.0.57
Diffstat (limited to 'reloadMtime.go')
-rw-r--r--reloadMtime.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/reloadMtime.go b/reloadMtime.go
index 7c18e9f..99869a7 100644
--- a/reloadMtime.go
+++ b/reloadMtime.go
@@ -119,6 +119,31 @@ func (repo *Repo) changedHead() bool {
return true
}
+// check the mtime of the .git/config file
+func (repo *Repo) changedConfig() bool {
+ fname := ".git/config"
+ fileTime := repo.Mtime(fname)
+ if fileTime == nil {
+ // .git/config doesn't exist. something is wrong!
+ log.Info("gitpb .git/config is missing", repo.GetGoPath())
+ return false
+ }
+ mtime := timestamppb.New(*fileTime)
+ pbtime := repo.Times.MtimeConfig
+ if pbtime == nil { // this can happen?
+ repo.Times.MtimeConfig = 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.MtimeConfig = mtime
+ return true
+}
+
func (repo *Repo) changedIndex() bool {
fname := ".git/index"
fileTime := repo.Mtime(fname)
@@ -154,6 +179,9 @@ func (repo *Repo) reloadMtimes() bool {
if repo.changedIndex() {
changed = true
}
+ if repo.changedConfig() {
+ changed = true
+ }
if repo.changedDir() {
// changed = true
}
@@ -171,6 +199,9 @@ func (repo *Repo) DidRepoChange() bool {
if repo.didFileChange(".git/index", repo.Times.MtimeIndex) {
return true
}
+ if repo.didFileChange(".git/config", repo.Times.MtimeConfig) {
+ return true
+ }
if repo.didFileChange(".git", repo.Times.MtimeDir) {
// todo: do something with CheckDirty()
// return true