Add compacted_at_commit field and git commit capture during compaction
- Add compacted_at_commit field to Issue type (bd-405) - Add database schema and migration for new field - Create GetCurrentCommitHash() helper function - Update ApplyCompaction to store git commit hash (bd-395) - Update compaction calls to capture current commit - Update tests to verify commit hash storage - All tests passing Amp-Thread-ID: https://ampcode.com/threads/T-5518cccb-7fc9-4dcd-ba5a-e22cd10e45d7 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -279,8 +279,8 @@ func (s *SQLiteStorage) CheckEligibility(ctx context.Context, issueID string, ti
|
||||
}
|
||||
|
||||
// ApplyCompaction updates the compaction metadata for an issue after successfully compacting it.
|
||||
// This sets compaction_level, compacted_at, and original_size fields.
|
||||
func (s *SQLiteStorage) ApplyCompaction(ctx context.Context, issueID string, level int, originalSize int, compressedSize int) error {
|
||||
// This sets compaction_level, compacted_at, compacted_at_commit, and original_size fields.
|
||||
func (s *SQLiteStorage) ApplyCompaction(ctx context.Context, issueID string, level int, originalSize int, compressedSize int, commitHash string) error {
|
||||
now := time.Now().UTC()
|
||||
|
||||
tx, err := s.db.BeginTx(ctx, nil)
|
||||
@@ -289,14 +289,20 @@ func (s *SQLiteStorage) ApplyCompaction(ctx context.Context, issueID string, lev
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
var commitHashPtr *string
|
||||
if commitHash != "" {
|
||||
commitHashPtr = &commitHash
|
||||
}
|
||||
|
||||
_, err = tx.ExecContext(ctx, `
|
||||
UPDATE issues
|
||||
SET compaction_level = ?,
|
||||
compacted_at = ?,
|
||||
compacted_at_commit = ?,
|
||||
original_size = ?,
|
||||
updated_at = ?
|
||||
WHERE id = ?
|
||||
`, level, now, originalSize, now, issueID)
|
||||
`, level, now, commitHashPtr, originalSize, now, issueID)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to apply compaction metadata: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user