Skip to content

Commit b1b70b2

Browse files
committed
wip: git: write-tree
1 parent 59015a2 commit b1b70b2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

internal/git/diff_wt.go renamed to internal/git/index_wt.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,13 @@ func (w *Worktree) DiffIndex(ctx context.Context, treeish string) ([]FileStatus,
7676

7777
return files, nil
7878
}
79+
80+
// WriteIndexTree writes the current index to a new tree object.
81+
func (w *Worktree) WriteIndexTree(ctx context.Context) (Hash, error) {
82+
cmd := w.gitCmd(ctx, "write-tree")
83+
out, err := cmd.OutputString(w.exec)
84+
if err != nil {
85+
return "", fmt.Errorf("write-tree: %w", err)
86+
}
87+
return Hash(out), nil
88+
}

0 commit comments

Comments
 (0)