@@ -16,6 +16,7 @@ import (
1616 "github.com/go-git/go-git/v5/storage/memory"
1717 "github.com/openshift-knative/deviate/pkg/config/git"
1818 "github.com/openshift-knative/deviate/pkg/errors"
19+ "github.com/openshift-knative/deviate/pkg/files"
1920)
2021
2122func (r Repository ) Checkout (remote git.Remote , branch string ) git.Checkout { //nolint:ireturn
@@ -86,7 +87,7 @@ func (o onGoingCheckout) As(branch string) error {
8687 return nil
8788}
8889
89- func (o onGoingCheckout ) OntoWorkspace () error {
90+ func (o onGoingCheckout ) OntoWorkspace (filters files. Filters ) error {
9091 coOpts := & gitv5.CloneOptions {
9192 URL : "file://" + o .repo .Project .Path ,
9293 ReferenceName : plumbing .NewBranchReferenceName (o .branch ),
@@ -98,18 +99,21 @@ func (o onGoingCheckout) OntoWorkspace() error {
9899 if err != nil {
99100 return errors .Wrap (err , ErrLocalOperationFailed )
100101 }
101- return o .applyTree (wt , "/" )
102+ return o .applyTree (wt , "/" , filters )
102103}
103104
104- func (o onGoingCheckout ) applyTree (fs billy.Filesystem , dir string ) error {
105- files , err := fs .ReadDir (dir )
105+ func (o onGoingCheckout ) applyTree (fs billy.Filesystem , dir string , filters files. Filters ) error {
106+ infos , err := fs .ReadDir (dir )
106107 if err != nil {
107108 return errors .Wrap (err , ErrLocalOperationFailed )
108109 }
109- for _ , f := range files {
110+ for _ , f := range infos {
110111 fp := path .Join (dir , f .Name ())
112+ if ! filters .Matches (fp ) {
113+ continue
114+ }
111115 if f .IsDir () {
112- err = o .applyTree (fs , fp )
116+ err = o .applyTree (fs , fp , filters )
113117 if err != nil {
114118 return err
115119 }
0 commit comments