From 6cbd7e67af54a9854740aeab288bc9e447569337 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 5 Jan 2025 19:45:29 -0600 Subject: attempt custom branch names --- configLookup.go | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'configLookup.go') diff --git a/configLookup.go b/configLookup.go index 8715f40..e829091 100644 --- a/configLookup.go +++ b/configLookup.go @@ -260,3 +260,65 @@ func (fc *ForgeConfigs) FindUserBranch(thing string) string { return match.UserBranchName } + +// allows custom devel branch names in the forge config +func (fc *ForgeConfigs) FindDevelBranch(thing string) string { + var match *ForgeConfig + + all := fc.SortByGoPath() // get the list of repos + for all.Scan() { + r := all.Next() + if r.GoPath == thing { + if r.DevelBranchName != "" { + return r.DevelBranchName + } + } + base := filepath.Base(r.GoPath) + if base == thing { + if r.DevelBranchName != "" { + return r.DevelBranchName + } + } + if r.Directory { + if strings.HasPrefix(thing, r.GoPath) { + match = r + } + } + } + if match == nil { + return "" + } + + return match.DevelBranchName +} + +// allows custom devel branch names in the forge config +func (fc *ForgeConfigs) FindMasterBranch(thing string) string { + var match *ForgeConfig + + all := fc.SortByGoPath() // get the list of repos + for all.Scan() { + r := all.Next() + if r.GoPath == thing { + if r.MasterBranchName != "" { + return r.MasterBranchName + } + } + base := filepath.Base(r.GoPath) + if base == thing { + if r.MasterBranchName != "" { + return r.MasterBranchName + } + } + if r.Directory { + if strings.HasPrefix(thing, r.GoPath) { + match = r + } + } + } + if match == nil { + return "" + } + + return match.MasterBranchName +} -- cgit v1.2.3