summaryrefslogtreecommitdiff
path: root/doDirty.go
blob: e7c5b8be543aa662ab632084178f5681f9e93b4c (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
package main

import (
	"time"

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

func doDirty() {
	findAll() // select all the repos
	doCheckDirtyAndConfigSave()
	me.found = new(gitpb.Repos)
	findDirty()
	me.forge.PrintHumanTableDirty(me.found)
}

func doCheckDirtyAndConfigSave() {
	var count int
	now := time.Now()
	// log.Info("before findAll()")
	all := me.found.SortByFullPath()
	for all.Scan() {
		repo := all.Next()
		// log.Info("before isDirty()")
		dirty := repo.IsDirty()
		if repo.CheckDirty() {
			count += 1
			if me.found.AppendByGoPath(repo) {
				log.Info("doCheckDirtyAndConfigSave() repo already existed", repo.GetGoPath())
			}
			if !dirty {
				configSave = true
			}
		} else {
			if dirty {
				configSave = true
			}
		}
	}
	log.Printf("dirty check (%d repos) took:%s\n", count, shell.FormatDuration(time.Since(now)))
	me.forge.SetConfigSave(configSave)
}