// Copyright 2017-2025 WIT.COM Inc. All rights reserved. // Use of this source code is governed by the GPL 3.0 package main import ( "time" "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) func doDirty() { doCheckDirtyAndConfigSave() if allerr := me.forge.RillRepos(checkNormalRepoState); len(allerr) != 0 { log.Info("Some repos are not in a 'normal' state. error count =", len(allerr)) for repo, err := range allerr { log.Info("repo not normal", repo.GetFullPath(), err) } } found := findDirty() if argv.Verbose { me.forge.PrintHumanTableDirty(found) } else { me.forge.PrintHumanTable(found) } } // 99% of the time, the repos during development should be on your user branch. // error out if it's not // this checks to see if a devel and user branch exist // this needs to run each time in case repos were added manually by the user // this also verifies that func checkNormalRepoState(repo *gitpb.Repo) error { if err := repo.MakeLocalDevelBranch(); err != nil { return err } if repo.GetCurrentBranchName() != repo.GetUserBranchName() { return repo.CheckoutUser() } return nil } func straightCheckDirty() int { var count int // var total int // now := time.Now() for repo := range me.forge.Repos.IterAll() { // total += 1 if repo.IsDirty() { count += 1 } } // log.Printf("rill dirty check (%d dirty repos) (%d total repos) took:%s\n", count, total, shell.FormatDuration(time.Since(now))) return count } func doCheckDirty(repo *gitpb.Repo) error { repo.CheckDirty() // reset these in here for now if repo.GetTargetVersion() != "" { repo.TargetVersion = "" me.forge.SetConfigSave(true) } return nil } // recheck every repo's dirty state according to 'git' func doCheckDirtyAndConfigSave() { start := straightCheckDirty() now := time.Now() me.forge.RillFuncError(doCheckDirty) end := straightCheckDirty() log.Printf("dirty check (%d dirty repos) (%d total repos) took:%s\n", end, me.forge.Repos.Len(), shell.FormatDuration(time.Since(now))) if start != end { // todo: use internal forgepb configsave flag. should work? me.forge.SetConfigSave(true) me.forge.ConfigSave() } }