功能补齐、查看git提交历史

This commit is contained in:
2026-06-12 09:21:37 +08:00
parent fba3a14367
commit 2a9661a6ef
12 changed files with 329 additions and 9 deletions
+24
View File
@@ -79,6 +79,18 @@ func (s *gitOpsService) PushOnMain(ctx context.Context, c Caller, wsID uuid.UUID
return nil
}
func (s *gitOpsService) LogOnMain(ctx context.Context, c Caller, wsID uuid.UUID, n int) ([]git.Commit, error) {
ws, err := s.guardWorkspaceRead(ctx, c, wsID)
if err != nil {
return nil, err
}
commits, err := s.gitr.Log(ctx, ws.MainPath, n)
if err != nil {
return nil, errs.Wrap(err, errs.CodeGitCmdFailed, "git log")
}
return commits, nil
}
// ===== Worktree =====
func (s *gitOpsService) StatusOnWorktree(ctx context.Context, c Caller, wtID uuid.UUID) ([]git.FileStatus, error) {
@@ -133,6 +145,18 @@ func (s *gitOpsService) PushOnWorktree(ctx context.Context, c Caller, wtID uuid.
return nil
}
func (s *gitOpsService) LogOnWorktree(ctx context.Context, c Caller, wtID uuid.UUID, n int) ([]git.Commit, error) {
wt, _, err := s.guardWorktreeRead(ctx, c, wtID)
if err != nil {
return nil, err
}
commits, err := s.gitr.Log(ctx, wt.Path, n)
if err != nil {
return nil, errs.Wrap(err, errs.CodeGitCmdFailed, "git log")
}
return commits, nil
}
// ===== guards =====
func (s *gitOpsService) guardWorkspaceRead(ctx context.Context, c Caller, wsID uuid.UUID) (*Workspace, error) {