diff options
| author | Jeff Carr <[email protected]> | 2024-12-15 15:53:08 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-15 15:53:08 -0600 |
| commit | 01b332ceb81945ae5a5cb2b1677ab985723dc75e (patch) | |
| tree | ddb0d33495106e19df02e4e3aa40cd9381656fcf /isTracked.go | |
| parent | 5006d718fd59a3ac964750bb7890c9e0e262811b (diff) | |
all of this code still sucksv0.0.31
Diffstat (limited to 'isTracked.go')
| -rw-r--r-- | isTracked.go | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/isTracked.go b/isTracked.go index 2fc8ddf..b15db02 100644 --- a/isTracked.go +++ b/isTracked.go @@ -1,7 +1,10 @@ package gitpb import ( + "errors" "fmt" + + "go.wit.com/log" ) func (repo *Repo) isTracked(file string) (bool, error) { @@ -30,34 +33,40 @@ func (repo *Repo) isIgnored(file string) (bool, error) { return false, nil } -func (repo *Repo) RepoIgnoresGoMod() (bool, error) { +// is it a good idea to run go-mod-clean in this repo? +// for now, check if this repo should be ignored +// TODO: go.mod and go.sum should be moved to git tag metadata +func (repo *Repo) RepoIgnoresGoMod() error { file := "go.mod" if tracked, err := repo.isTracked(file); err != nil { - fmt.Printf("%s Error checking if %s tracked: %v\n", repo.GoPath, file, err) - return false, err + msg := fmt.Sprintf("%s Error checking if %s tracked: %v\n", repo.GoPath, file, err) + log.Info("gitpb:", msg) + return err } else { if tracked { - fmt.Printf("%s %s is tracked by Git.\n", repo.GoPath, file) - return false, nil + msg := fmt.Sprintf("%s %s is tracked by Git.\n", repo.GoPath, file) + log.Info("gitpb:", msg) + return errors.New(msg) } } if ignored, err := repo.isIgnored(file); err != nil { if err != nil { - fmt.Printf("%s Error checking if ignored: %v\n", repo.GoPath, err) - return false, err + msg := fmt.Sprintf("%s Error checking if ignored: %v\n", repo.GoPath, err) + log.Info("gitpb:", msg) + return err } } else { - if ignored { fmt.Printf("%s %s is ignored by Git.\n", repo.GoPath, file) - return true, nil + return nil } } - fmt.Printf("%s %s is neither tracked nor ignored by Git.\n", repo.GoPath, file) + msg := fmt.Sprintf("%s %s is neither tracked nor ignored by Git.\n", repo.GoPath, file) // this means, if you make a go.mod file, it'll add it to the repo to be tracked // so you need to either add it to .gitignore (this is what should happen) // or accept you want an auto-generated file to put endless garbage in your git repo // this obviously exposes my opinion on this subject matter - return false, nil + log.Info("gitpb:", msg) + return errors.New(msg) } |
