Add support for syncing issues across multiple projects/teams in all three tracker integrations, with shared infrastructure to avoid duplicating logic. Shared infrastructure (internal/tracker/multiproject.go): - ParseCommaSeparated: splits comma-separated config values - DeduplicateStrings: removes duplicates preserving order - ResolveProjectIDs: config precedence (CLI > plural > singular) Linear (closes #2791): - Tracker: map[string]*Client with per-team routing - FetchIssues iterates all teams, deduplicates by issue ID - UpdateIssue routes to owning team via FetchIssueByIdentifier - Config: linear.team_ids / LINEAR_TEAM_IDS + --team flag Jira: - projectKey string → projectKeys []string - FetchIssues uses JQL IN clause (single query, no iteration) - Config: jira.projects / JIRA_PROJECTS + --project flag ADO: - project string → projects []string - WIQL uses TeamProject IN clause (single query) - Config: ado.projects / AZURE_DEVOPS_PROJECTS + --project flag All singular config keys remain supported for backward compatibility. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package tracker
|
|
|
|
import "strings"
|
|
|
|
// ParseCommaSeparated splits a comma-separated string into trimmed, non-empty elements.
|
|
// Used by trackers that support multiple project/team IDs via config.
|
|
func ParseCommaSeparated(s string) []string {
|
|
parts := strings.Split(s, ",")
|
|
result := make([]string, 0, len(parts))
|
|
for _, p := range parts {
|
|
trimmed := strings.TrimSpace(p)
|
|
if trimmed != "" {
|
|
result = append(result, trimmed)
|
|
}
|
|
}
|
|
return result
|
|
}
|
|
|
|
// DeduplicateStrings returns a slice with duplicates removed, preserving order.
|
|
func DeduplicateStrings(ss []string) []string {
|
|
seen := make(map[string]bool, len(ss))
|
|
result := make([]string, 0, len(ss))
|
|
for _, s := range ss {
|
|
if !seen[s] {
|
|
seen[s] = true
|
|
result = append(result, s)
|
|
}
|
|
}
|
|
return result
|
|
}
|
|
|
|
// ResolveProjectIDs resolves the effective project/team IDs from config sources.
|
|
// It checks plural first, then singular, and deduplicates the result.
|
|
// The cliOverride takes highest precedence when non-empty.
|
|
func ResolveProjectIDs(cliOverride []string, pluralVal, singularVal string) []string {
|
|
if len(cliOverride) > 0 {
|
|
return DeduplicateStrings(cliOverride)
|
|
}
|
|
if pluralVal != "" {
|
|
parsed := ParseCommaSeparated(pluralVal)
|
|
if len(parsed) > 0 {
|
|
return DeduplicateStrings(parsed)
|
|
}
|
|
}
|
|
if singularVal != "" {
|
|
return []string{singularVal}
|
|
}
|
|
return nil
|
|
}
|