Push bead labels (issue_type-derived + custom labels) to Linear on `bd linear sync --push`, closing #3753. Why: completes the #3772 pair - #3772 gave push-direction state mapping its outbound overrides, this PR makes labels flow beads -> Linear (they previously only flowed Linear -> beads, so pushed issues arrived label-less). Adds paginated `GetTeamLabels`, a per-team `LabelCache`, inversion of `label_type_map` for the push direction, label-aware `PushFieldsEqual` skip logic, and warnings for labels missing on the Linear team. Author rebased onto main same-day when asked; rebase verified clean against the pre-rebase diff (changed lines byte-identical, both #3772 and #3776 test sets preserved in mapping_test.go). Local verification: gofmt clean, `CGO_ENABLED=0 go build -tags gms_pure_go ./...` ok, `go test ./internal/linear/...` ok, `go vet` clean. Failing PR checks (errcheck in formula_schema.go, testing.Short policy, unclaim/update claim tests) are base-branch breakage present on main at rebase time, since fixed by #4623 - unrelated to this change. Co-Authored-By: kev <kglynn@pryoninc.com>
91 lines
2.3 KiB
Go
91 lines
2.3 KiB
Go
package linear
|
|
|
|
import (
|
|
"github.com/steveyegge/beads/internal/tracker"
|
|
"github.com/steveyegge/beads/internal/types"
|
|
)
|
|
|
|
// linearFieldMapper implements tracker.FieldMapper for Linear.
|
|
type linearFieldMapper struct {
|
|
config *MappingConfig
|
|
labelCache *LabelCache // optional; when set, IssueToTracker includes labelIds
|
|
}
|
|
|
|
func (m *linearFieldMapper) PriorityToBeads(trackerPriority interface{}) int {
|
|
if p, ok := trackerPriority.(int); ok {
|
|
return PriorityToBeads(p, m.config)
|
|
}
|
|
return 2
|
|
}
|
|
|
|
func (m *linearFieldMapper) PriorityToTracker(beadsPriority int) interface{} {
|
|
return PriorityToLinear(beadsPriority, m.config)
|
|
}
|
|
|
|
func (m *linearFieldMapper) StatusToBeads(trackerState interface{}) types.Status {
|
|
if state, ok := trackerState.(*State); ok {
|
|
return StateToBeadsStatus(state, m.config)
|
|
}
|
|
return types.StatusOpen
|
|
}
|
|
|
|
func (m *linearFieldMapper) StatusToTracker(beadsStatus types.Status) interface{} {
|
|
return StatusToLinearStateType(beadsStatus)
|
|
}
|
|
|
|
func (m *linearFieldMapper) TypeToBeads(trackerType interface{}) types.IssueType {
|
|
if labels, ok := trackerType.(*Labels); ok {
|
|
return LabelToIssueType(labels, m.config)
|
|
}
|
|
return types.TypeTask
|
|
}
|
|
|
|
func (m *linearFieldMapper) TypeToTracker(beadsType types.IssueType) interface{} {
|
|
return string(beadsType)
|
|
}
|
|
|
|
func (m *linearFieldMapper) IssueToBeads(ti *tracker.TrackerIssue) *tracker.IssueConversion {
|
|
li, ok := ti.Raw.(*Issue)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
|
|
conv := IssueToBeads(li, m.config)
|
|
if conv == nil {
|
|
return nil
|
|
}
|
|
|
|
issue, ok := conv.Issue.(*types.Issue)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
|
|
var deps []tracker.DependencyInfo
|
|
for _, d := range conv.Dependencies {
|
|
deps = append(deps, tracker.DependencyInfo{
|
|
FromExternalID: d.FromLinearID,
|
|
ToExternalID: d.ToLinearID,
|
|
Type: d.Type,
|
|
Source: tracker.DependencySource(d.Source),
|
|
})
|
|
}
|
|
|
|
return &tracker.IssueConversion{
|
|
Issue: issue,
|
|
Dependencies: deps,
|
|
}
|
|
}
|
|
|
|
func (m *linearFieldMapper) IssueToTracker(issue *types.Issue) map[string]interface{} {
|
|
updates := map[string]interface{}{
|
|
"title": issue.Title,
|
|
"description": issue.Description,
|
|
"priority": PriorityToLinear(issue.Priority, m.config),
|
|
}
|
|
if m.labelCache != nil {
|
|
if ids, _ := ResolveLabelIDs(issue, m.labelCache, m.config); len(ids) > 0 {
|
|
updates["labelIds"] = ids
|
|
}
|
|
}
|
|
return updates
|
|
}
|