2024-12-05 12:29:47 -06:00
|
|
|
package main
|
|
|
|
|
2025-01-05 01:18:47 -06:00
|
|
|
import (
|
|
|
|
"go.wit.com/lib/protobuf/gitpb"
|
|
|
|
)
|
|
|
|
|
|
|
|
// this populates a slice of protobuf records representing each git repo
|
|
|
|
// var me.found []*gitpb.Repo
|
|
|
|
//
|
|
|
|
// so, it makes a subset of repos that are then used performing actions on
|
|
|
|
//
|
|
|
|
// by default, it adds every repo
|
|
|
|
|
2024-12-27 03:39:53 -06:00
|
|
|
func (f *FindCmd) findRepos() {
|
|
|
|
if f == nil {
|
|
|
|
findMine()
|
|
|
|
return
|
|
|
|
}
|
2024-12-05 12:29:47 -06:00
|
|
|
|
2025-01-29 19:59:55 -06:00
|
|
|
if f.Pub != nil {
|
|
|
|
findPublishable()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-12-27 03:39:53 -06:00
|
|
|
if f.All {
|
2025-01-05 01:18:47 -06:00
|
|
|
findAll()
|
2024-12-27 03:39:53 -06:00
|
|
|
return
|
|
|
|
}
|
2024-12-05 12:29:47 -06:00
|
|
|
|
2024-12-27 03:39:53 -06:00
|
|
|
if f.Private {
|
|
|
|
findPrivate()
|
|
|
|
return
|
2024-12-05 14:17:50 -06:00
|
|
|
}
|
|
|
|
|
2024-12-27 03:39:53 -06:00
|
|
|
if f.Mine {
|
2024-12-05 14:17:50 -06:00
|
|
|
findMine()
|
2024-12-27 03:39:53 -06:00
|
|
|
return
|
|
|
|
}
|
2025-01-05 01:18:47 -06:00
|
|
|
|
2024-12-27 03:39:53 -06:00
|
|
|
if f.Favorites {
|
|
|
|
findFavorites()
|
|
|
|
return
|
2024-12-05 14:17:50 -06:00
|
|
|
}
|
2024-12-27 03:39:53 -06:00
|
|
|
|
2025-01-05 01:18:47 -06:00
|
|
|
if f.Dirty {
|
|
|
|
findDirty()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-01-18 23:25:55 -06:00
|
|
|
if f.User {
|
|
|
|
findUser()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-01-05 01:18:47 -06:00
|
|
|
findAll()
|
2024-12-27 03:39:53 -06:00
|
|
|
}
|
|
|
|
|
2024-12-05 14:17:50 -06:00
|
|
|
func findPrivate() {
|
2024-12-17 06:36:00 -06:00
|
|
|
all := me.forge.Repos.SortByFullPath()
|
2024-12-11 19:32:04 -06:00
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2024-12-17 06:36:00 -06:00
|
|
|
if me.forge.Config.IsPrivate(repo.GetGoPath()) {
|
2025-01-13 04:14:06 -06:00
|
|
|
me.found.AppendByGoPath(repo)
|
2024-12-05 14:17:50 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// finds repos that are writable
|
|
|
|
func findMine() {
|
|
|
|
// log.Printf("get mine %s\n", me.forge.GetGoSrc())
|
2024-12-17 06:36:00 -06:00
|
|
|
all := me.forge.Repos.SortByFullPath()
|
2024-12-11 19:32:04 -06:00
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2024-12-17 06:36:00 -06:00
|
|
|
if me.forge.Config.IsWritable(repo.GetGoPath()) {
|
2025-01-13 04:14:06 -06:00
|
|
|
me.found.AppendByGoPath(repo)
|
2024-12-05 14:17:50 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-05 01:18:47 -06:00
|
|
|
// finds repos the user has marked as favorites in the forge .config
|
2024-12-05 14:17:50 -06:00
|
|
|
func findFavorites() {
|
|
|
|
// log.Printf("get favorites %s\n", me.forge.GetGoSrc())
|
2024-12-17 06:36:00 -06:00
|
|
|
all := me.forge.Repos.SortByFullPath()
|
2024-12-11 19:32:04 -06:00
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2024-12-17 06:36:00 -06:00
|
|
|
if me.forge.Config.IsFavorite(repo.GetGoPath()) {
|
2025-01-13 04:14:06 -06:00
|
|
|
me.found.AppendByGoPath(repo)
|
2024-12-05 14:17:50 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-05 01:18:47 -06:00
|
|
|
// finds repos that git is reporting as dirty
|
|
|
|
func findDirty() {
|
|
|
|
all := me.forge.Repos.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
var repo *gitpb.Repo
|
|
|
|
repo = all.Next()
|
|
|
|
if repo.IsDirty() {
|
2025-01-13 04:14:06 -06:00
|
|
|
me.found.AppendByGoPath(repo)
|
2025-01-05 01:18:47 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func findAll() {
|
2024-12-17 06:36:00 -06:00
|
|
|
all := me.forge.Repos.SortByFullPath()
|
2024-12-11 19:32:04 -06:00
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2025-01-13 04:14:06 -06:00
|
|
|
me.found.AppendByGoPath(repo)
|
2024-12-05 12:29:47 -06:00
|
|
|
}
|
|
|
|
}
|
2025-01-18 23:25:55 -06:00
|
|
|
|
|
|
|
func findUser() {
|
|
|
|
all := me.forge.Repos.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
if repo.GetCurrentBranchName() == repo.GetUserBranchName() {
|
|
|
|
me.found.AppendByGoPath(repo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2025-01-28 13:58:41 -06:00
|
|
|
|
2025-01-29 19:59:55 -06:00
|
|
|
func findPublishable() {
|
|
|
|
all := me.forge.Repos.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
if repo.GetTargetVersion() == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
me.found.AppendByGoPath(repo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-28 13:58:41 -06:00
|
|
|
func findReposWithPatches() {
|
|
|
|
all := me.forge.Repos.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2025-01-28 17:35:18 -06:00
|
|
|
if repo.GetUserVersion() == "" || repo.GetUserVersion() == "uerr" {
|
|
|
|
continue
|
|
|
|
}
|
2025-01-28 13:58:41 -06:00
|
|
|
if repo.IsDirty() {
|
|
|
|
me.found.AppendByGoPath(repo)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if repo.GetUserVersion() != repo.GetDevelVersion() {
|
|
|
|
me.found.AppendByGoPath(repo)
|
2025-01-28 17:35:18 -06:00
|
|
|
continue
|
2025-01-28 13:58:41 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|