diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2026-01-30 20:25:26 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2026-01-31 16:07:13 +0000 |
| commit | 3576455960ee88cefa43cad0bdfd1458549569b9 (patch) | |
| tree | b0943ccce2feb664e2a30dd2462d99cf13fc4bf7 /pkg/aflow/flow/patching/actions.go | |
| parent | afcca7fa917427568d76a8295ff9f1e88824c1fe (diff) | |
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.
Diffstat (limited to 'pkg/aflow/flow/patching/actions.go')
| -rw-r--r-- | pkg/aflow/flow/patching/actions.go | 32 |
1 files changed, 32 insertions, 0 deletions
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 +} |
