You've already forked agentic-coding-workflow
bugfix
This commit is contained in:
@@ -77,6 +77,7 @@ type fakeGitOpsSvc struct {
|
||||
statusFiles []git.FileStatus
|
||||
lastTarget string // "main:<wsID>" / "worktree:<wtID>"
|
||||
lastCommit workspace.CommitInput
|
||||
diffText string
|
||||
}
|
||||
|
||||
func (f *fakeGitOpsSvc) StatusOnMain(_ context.Context, _ workspace.Caller, wsID uuid.UUID) ([]git.FileStatus, error) {
|
||||
@@ -113,6 +114,14 @@ func (f *fakeGitOpsSvc) LogOnWorktree(_ context.Context, _ workspace.Caller, wtI
|
||||
f.lastTarget = "worktree:" + wtID.String()
|
||||
return nil, nil
|
||||
}
|
||||
func (f *fakeGitOpsSvc) DiffOnMain(_ context.Context, _ workspace.Caller, wsID uuid.UUID, _ git.DiffOptions) (git.DiffResult, error) {
|
||||
f.lastTarget = "main:" + wsID.String()
|
||||
return git.DiffResult{Diff: f.diffText}, nil
|
||||
}
|
||||
func (f *fakeGitOpsSvc) DiffOnWorktree(_ context.Context, _ workspace.Caller, wtID uuid.UUID, _ git.DiffOptions) (git.DiffResult, error) {
|
||||
f.lastTarget = "worktree:" + wtID.String()
|
||||
return git.DiffResult{Diff: f.diffText}, nil
|
||||
}
|
||||
|
||||
// wsTestDeps 在 testDeps 基础上挂一个已存在的 workspace + worktree 服务。
|
||||
func wsTestDeps() (ServerDeps, *fakeWorkspaceSvc, *fakeWorktreeSvc, *fakeGitOpsSvc) {
|
||||
@@ -318,3 +327,25 @@ func TestGitCommit_Worktree(t *testing.T) {
|
||||
assert.False(t, gitSvc.lastCommit.AddAll)
|
||||
assert.True(t, gitSvc.lastCommit.Push)
|
||||
}
|
||||
|
||||
func TestGitDiff_MainAndScope(t *testing.T) {
|
||||
deps, _, _, gitSvc := wsTestDeps()
|
||||
gitSvc.diffText = "diff --git a/x b/x\n+added\n"
|
||||
|
||||
result, err := callTool(ctxWithAuth(Scope{}), deps, "git_diff", map[string]any{
|
||||
"workspace_id": testWSID.String(),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.False(t, result.IsError)
|
||||
var out gitDiffOut
|
||||
unmarshalStructured(t, result, &out)
|
||||
assert.Contains(t, out.Diff, "+added")
|
||||
assert.Equal(t, "main:"+testWSID.String(), gitSvc.lastTarget)
|
||||
|
||||
// scope to a different project => denied
|
||||
result, err = callTool(ctxWithAuth(Scope{ProjectIDs: []uuid.UUID{uuid.New()}}), deps, "git_diff", map[string]any{
|
||||
"workspace_id": testWSID.String(),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.True(t, result.IsError)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user