@@ -4,19 +4,22 @@ import (
4
4
"context"
5
5
"fmt"
6
6
7
+ "github.com/github/git-bundle-server/cmd/utils"
7
8
"github.com/github/git-bundle-server/internal/argparse"
8
9
"github.com/github/git-bundle-server/internal/bundles"
9
10
"github.com/github/git-bundle-server/internal/core"
10
11
"github.com/github/git-bundle-server/internal/log"
11
12
)
12
13
13
14
type updateCmd struct {
14
- logger log.TraceLogger
15
+ logger log.TraceLogger
16
+ container * utils.DependencyContainer
15
17
}
16
18
17
- func NewUpdateCommand (logger log.TraceLogger ) argparse.Subcommand {
19
+ func NewUpdateCommand (logger log.TraceLogger , container * utils. DependencyContainer ) argparse.Subcommand {
18
20
return & updateCmd {
19
- logger : logger ,
21
+ logger : logger ,
22
+ container : container ,
20
23
}
21
24
}
22
25
@@ -36,18 +39,21 @@ func (u *updateCmd) Run(ctx context.Context, args []string) error {
36
39
route := parser .PositionalString ("route" , "the route to update" )
37
40
parser .Parse (ctx , args )
38
41
39
- repo , err := core .CreateRepository (* route )
42
+ repoProvider := utils .GetDependency [core.RepositoryProvider ](ctx , u .container )
43
+ bundleProvider := utils .GetDependency [bundles.BundleProvider ](ctx , u .container )
44
+
45
+ repo , err := repoProvider .CreateRepository (ctx , * route )
40
46
if err != nil {
41
47
return u .logger .Error (ctx , err )
42
48
}
43
49
44
- list , err := bundles .GetBundleList (repo )
50
+ list , err := bundleProvider .GetBundleList (ctx , repo )
45
51
if err != nil {
46
52
return u .logger .Errorf (ctx , "failed to load bundle list: %w" , err )
47
53
}
48
54
49
55
fmt .Printf ("Creating new incremental bundle\n " )
50
- bundle , err := bundles .CreateIncrementalBundle (repo , list )
56
+ bundle , err := bundleProvider .CreateIncrementalBundle (ctx , repo , list )
51
57
if err != nil {
52
58
return u .logger .Error (ctx , err )
53
59
}
@@ -60,13 +66,13 @@ func (u *updateCmd) Run(ctx context.Context, args []string) error {
60
66
list .Bundles [bundle .CreationToken ] = * bundle
61
67
62
68
fmt .Printf ("Collapsing bundle list\n " )
63
- err = bundles .CollapseList (repo , list )
69
+ err = bundleProvider .CollapseList (ctx , repo , list )
64
70
if err != nil {
65
71
return u .logger .Error (ctx , err )
66
72
}
67
73
68
74
fmt .Printf ("Writing updated bundle list\n " )
69
- listErr := bundles .WriteBundleList (list , repo )
75
+ listErr := bundleProvider .WriteBundleList (ctx , list , repo )
70
76
if listErr != nil {
71
77
return u .logger .Errorf (ctx , "failed to write bundle list: %w" , listErr )
72
78
}
0 commit comments