feat(hooks): add DeleteBranch for import branch cleanup
- Add DeleteBranch method to DoltStore for removing branches - Update hookPostMergeDolt to clean up import branches after merge - Completes hq-ew1mbr.9 git hook infrastructure Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
13af11768f
commit
62dd5f8585
@@ -553,6 +553,7 @@ func hookPostMergeDolt(beadsDir string) int {
|
|||||||
Merge(ctx context.Context, branch string) error
|
Merge(ctx context.Context, branch string) error
|
||||||
Commit(ctx context.Context, message string) error
|
Commit(ctx context.Context, message string) error
|
||||||
CurrentBranch(ctx context.Context) (string, error)
|
CurrentBranch(ctx context.Context) (string, error)
|
||||||
|
DeleteBranch(ctx context.Context, branch string) error
|
||||||
})
|
})
|
||||||
if !ok {
|
if !ok {
|
||||||
// Not a Dolt store with version control, use regular import
|
// Not a Dolt store with version control, use regular import
|
||||||
@@ -613,7 +614,11 @@ func hookPostMergeDolt(beadsDir string) int {
|
|||||||
// This is expected, not an error
|
// This is expected, not an error
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Delete import branch (need to add DeleteBranch method to DoltStore)
|
// Clean up import branch
|
||||||
|
if err := doltStore.DeleteBranch(ctx, importBranch); err != nil {
|
||||||
|
// Non-fatal - branch cleanup is best-effort
|
||||||
|
fmt.Fprintf(os.Stderr, "Warning: could not delete import branch %s: %v\n", importBranch, err)
|
||||||
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,6 +361,15 @@ func (s *DoltStore) CurrentBranch(ctx context.Context) (string, error) {
|
|||||||
return branch, nil
|
return branch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteBranch deletes a branch (used to clean up import branches)
|
||||||
|
func (s *DoltStore) DeleteBranch(ctx context.Context, branch string) error {
|
||||||
|
_, err := s.db.ExecContext(ctx, "CALL DOLT_BRANCH('-D', ?)", branch)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to delete branch %s: %w", branch, err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Log returns recent commit history
|
// Log returns recent commit history
|
||||||
func (s *DoltStore) Log(ctx context.Context, limit int) ([]CommitInfo, error) {
|
func (s *DoltStore) Log(ctx context.Context, limit int) ([]CommitInfo, error) {
|
||||||
rows, err := s.db.QueryContext(ctx, `
|
rows, err := s.db.QueryContext(ctx, `
|
||||||
|
|||||||
Reference in New Issue
Block a user