diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2026-02-02 08:17:28 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2026-02-02 09:22:43 +0000 |
| commit | 9a3a4862049c464b0fc12dff6a9bfc49e2d8bf03 (patch) | |
| tree | 40b78b34f2201ecffdc88fc84e645eb1af72ce35 /pkg | |
| parent | 62be7008f950a8b59112b792a9099734ae54c157 (diff) | |
pkg/aflow/flow/patching: fix getting list of recent commits
We need to run git log in the master git repo b/c out KernelSrc/KernelScratchSrc
are shallow checkouts that don't have history.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/aflow/flow/patching/actions.go | 20 | ||||
| -rw-r--r-- | pkg/aflow/flow/patching/actions_test.go | 9 | ||||
| -rw-r--r-- | pkg/aflow/test_action.go | 3 |
3 files changed, 21 insertions, 11 deletions
diff --git a/pkg/aflow/flow/patching/actions.go b/pkg/aflow/flow/patching/actions.go index d42c24fa1..bea70e978 100644 --- a/pkg/aflow/flow/patching/actions.go +++ b/pkg/aflow/flow/patching/actions.go @@ -114,7 +114,6 @@ func maintainers(ctx *aflow.Context, args maintainersArgs) (maintainersResult, e var getRecentCommits = aflow.NewFuncAction("get-recent-commits", recentCommits) type recentCommitsArgs struct { - KernelSrc string KernelCommit string PatchDiff string } @@ -132,11 +131,16 @@ func recentCommits(ctx *aflow.Context, args recentCommitsArgs) (recentCommitsRes if len(files) == 0 { return res, aflow.FlowError(errors.New("patch diff does not contain any modified files")) } - gitArgs := append([]string{"log", "--format=%s", "--no-merges", "-n", "20", args.KernelCommit}, files...) - output, err := osutil.RunCmd(10*time.Minute, args.KernelSrc, "git", gitArgs...) - if err != nil { - return res, aflow.FlowError(fmt.Errorf("%w\n%s", err, output)) - } - res.RecentCommits = string(output) - return res, nil + // We need to run git log in the master git repo b/c out KernelSrc/KernelScratchSrc + // are shallow checkouts that don't have history. + err := kernel.UseLinuxRepo(ctx, func(kernelRepoDir string, _ vcs.Repo) error { + gitArgs := append([]string{"log", "--format=%s", "--no-merges", "-n", "20", args.KernelCommit}, files...) + output, err := osutil.RunCmd(10*time.Minute, kernelRepoDir, "git", gitArgs...) + if err != nil { + return aflow.FlowError(fmt.Errorf("%w\n%s", err, output)) + } + res.RecentCommits = string(output) + return nil + }) + return res, err } diff --git a/pkg/aflow/flow/patching/actions_test.go b/pkg/aflow/flow/patching/actions_test.go index c6f3011e7..c2e18141b 100644 --- a/pkg/aflow/flow/patching/actions_test.go +++ b/pkg/aflow/flow/patching/actions_test.go @@ -9,6 +9,8 @@ import ( "testing" "github.com/google/syzkaller/pkg/aflow" + "github.com/google/syzkaller/pkg/osutil" + "github.com/stretchr/testify/require" ) func TestRecentCommits(t *testing.T) { @@ -17,8 +19,11 @@ func TestRecentCommits(t *testing.T) { if os.Getenv("CI") != "" { t.Skip("skipping on CI because of shallow git checkout") } - aflow.TestAction(t, getRecentCommits, recentCommitsArgs{ - KernelSrc: filepath.FromSlash("../../../.."), + dir := t.TempDir() + require.NoError(t, osutil.MkdirAll(filepath.Join(dir, "repo"))) + require.NoError(t, os.Symlink(osutil.Abs(filepath.FromSlash("../../../..")), + filepath.Join(dir, "repo", "linux"))) + aflow.TestAction(t, getRecentCommits, dir, recentCommitsArgs{ KernelCommit: "e01a0ca6c12c9851ea7090f13879255ef82291e7", PatchDiff: ` diff --git a/dashboard/app/ai.go b/dashboard/app/ai.go diff --git a/pkg/aflow/test_action.go b/pkg/aflow/test_action.go index 0bf49ed69..a34410cf0 100644 --- a/pkg/aflow/test_action.go +++ b/pkg/aflow/test_action.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestAction(t *testing.T, a Action, initArgs, wantResults any, wantError string) { +func TestAction(t *testing.T, a Action, workdir string, initArgs, wantResults any, wantError string) { type tester interface { testVerify(t *testing.T, ctx *verifyContext, args, results any) ( map[string]any, map[string]any, func(map[string]any) map[string]any) @@ -22,6 +22,7 @@ func TestAction(t *testing.T, a Action, initArgs, wantResults any, wantError str // We don't init all fields, init more, if necessary. ctx := &Context{ state: args, + Workdir: workdir, onEvent: func(*trajectory.Span) error { return nil }, stubContext: stubContext{ timeNow: time.Now, |
