1// SPDX-FileCopyrightText: 2025 Romain Maneschi <romain@gitroot.dev>
2//
3// SPDX-License-Identifier: MIT
4
5package model
6
7import "iter"
8
9type Plugin interface {
10 Init(repoName string, initKind InitKind, serializedConf string) error
11 StartCommit(commit Commit) error
12 AddFile(file File) error
13 ModFile(file File) error
14 DelFile(file File) error
15 EndCommit(commit Commit) error
16 Finish() error
17}
18
19type ReportIterator interface {
20 Next() (report Report, ok bool)
21 ToSeq() iter.Seq[Report]
22}
23
24type PluginOption struct {
25 Reporter func(iterator ReportIterator) error
26}
27
28type PluginOptionWith = func(opt PluginOption) PluginOption
29
30func WithPluginReporter(reporter func(iterator ReportIterator) error) PluginOptionWith {
31 return func(opt PluginOption) PluginOption {
32 return PluginOption{Reporter: reporter}
33 }
34}