fix(merge): sort output by issue id (#859)
Ensure deterministic output when merging issues. Go map iteration order is non-deterministic, causing inconsistent merge results across runs. Sort result slice by ID before returning, matching bd export behavior. Fixes #853
This commit is contained in:
committed by
GitHub
parent
f37fe949e8
commit
ad44b32835
@@ -29,9 +29,11 @@ package merge
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"cmp"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
@@ -523,6 +525,11 @@ func Merge3WayWithTTL(base, left, right []Issue, ttl time.Duration, debug bool)
|
||||
}
|
||||
}
|
||||
|
||||
// Sort by ID for deterministic output (matches bd export behavior)
|
||||
slices.SortFunc(result, func(a, b Issue) int {
|
||||
return cmp.Compare(a.ID, b.ID)
|
||||
})
|
||||
|
||||
return result, conflicts
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user