This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

109 lines
2.6 KiB
Go

package issueops
import (
"context"
"database/sql"
"fmt"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/types"
)
// DiffInTx returns changes between two commits or branches by querying
// Dolt's dolt_diff() table function.
//
// nolint:gosec // G201: refs are validated by ValidateRef() - dolt_diff requires literal refs
func DiffInTx(ctx context.Context, tx *sql.Tx, fromRef, toRef string) ([]*storage.DiffEntry, error) {
if err := ValidateRef(fromRef); err != nil {
return nil, fmt.Errorf("invalid fromRef: %w", err)
}
if err := ValidateRef(toRef); err != nil {
return nil, fmt.Errorf("invalid toRef: %w", err)
}
query := fmt.Sprintf(`
SELECT
COALESCE(from_id, '') as from_id,
COALESCE(to_id, '') as to_id,
diff_type,
from_title, to_title,
from_description, to_description,
from_status, to_status,
from_priority, to_priority
FROM dolt_diff('%s', '%s', 'issues')
`, fromRef, toRef)
rows, err := tx.QueryContext(ctx, query)
if err != nil {
return nil, fmt.Errorf("failed to get diff: %w", err)
}
defer rows.Close()
var entries []*storage.DiffEntry
for rows.Next() {
var fromID, toID, diffType string
var fromTitle, toTitle, fromDesc, toDesc, fromStatus, toStatus *string
var fromPriority, toPriority *int
if err := rows.Scan(&fromID, &toID, &diffType,
&fromTitle, &toTitle,
&fromDesc, &toDesc,
&fromStatus, &toStatus,
&fromPriority, &toPriority); err != nil {
return nil, fmt.Errorf("failed to scan diff: %w", err)
}
entry := &storage.DiffEntry{
DiffType: diffType,
}
if toID != "" {
entry.IssueID = toID
} else {
entry.IssueID = fromID
}
// Build old value for modified/removed
if diffType != "added" && fromID != "" {
entry.OldValue = &types.Issue{
ID: fromID,
}
if fromTitle != nil {
entry.OldValue.Title = *fromTitle
}
if fromDesc != nil {
entry.OldValue.Description = *fromDesc
}
if fromStatus != nil {
entry.OldValue.Status = types.Status(*fromStatus)
}
if fromPriority != nil {
entry.OldValue.Priority = *fromPriority
}
}
// Build new value for modified/added
if diffType != "removed" && toID != "" {
entry.NewValue = &types.Issue{
ID: toID,
}
if toTitle != nil {
entry.NewValue.Title = *toTitle
}
if toDesc != nil {
entry.NewValue.Description = *toDesc
}
if toStatus != nil {
entry.NewValue.Status = types.Status(*toStatus)
}
if toPriority != nil {
entry.NewValue.Priority = *toPriority
}
}
entries = append(entries, entry)
}
return entries, rows.Err()
}