From 3576455960ee88cefa43cad0bdfd1458549569b9 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 30 Jan 2026 20:25:26 +0100 Subject: pkg/aflow/flow/patching: use recent commit subjects Give LLM the recent commit subjects when it generates description, so that it can use the same style. Add infrastrcuture to write end-to-end action tests to test it. --- pkg/aflow/flow/patching/actions.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'pkg/aflow/flow/patching/actions.go') diff --git a/pkg/aflow/flow/patching/actions.go b/pkg/aflow/flow/patching/actions.go index 2c98e9306..d42c24fa1 100644 --- a/pkg/aflow/flow/patching/actions.go +++ b/pkg/aflow/flow/patching/actions.go @@ -4,6 +4,8 @@ package patching import ( + "errors" + "fmt" "os/exec" "path/filepath" "strings" @@ -108,3 +110,33 @@ func maintainers(ctx *aflow.Context, args maintainersArgs) (maintainersResult, e } return res, nil } + +var getRecentCommits = aflow.NewFuncAction("get-recent-commits", recentCommits) + +type recentCommitsArgs struct { + KernelSrc string + KernelCommit string + PatchDiff string +} + +type recentCommitsResult struct { + RecentCommits string +} + +func recentCommits(ctx *aflow.Context, args recentCommitsArgs) (recentCommitsResult, error) { + var res recentCommitsResult + var files []string + for _, file := range vcs.ParseGitDiff([]byte(args.PatchDiff)) { + files = append(files, file.Name) + } + 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 +} -- cgit mrf-deployment