Skip to content

Commit 86e1328

Browse files
authored
Merge pull request #104 from devtron-labs/git-diff-optimise
git diff optimisation with --name-only
2 parents a8e6e8b + 26df75f commit 86e1328

21 files changed

+1168
-818
lines changed

api/GrpcHandler.go

+26-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type GrpcHandler interface {
4343
RefreshGitMaterial(ctx context.Context, req *pb.RefreshGitMaterialRequest) (*pb.RefreshGitMaterialResponse, error)
4444
ReloadAllMaterial(ctx context.Context, req *pb.Empty) (*pb.Empty, error)
4545
ReloadMaterial(ctx context.Context, req *pb.ReloadMaterialRequest) (*pb.GenericResponse, error)
46+
ReloadMaterials(ctx context.Context, req *pb.ReloadMaterialsRequest) (*pb.GenericResponse, error)
4647
GetChangesInRelease(ctx context.Context, req *pb.ReleaseChangeRequest) (*pb.GitChanges, error)
4748
GetWebhookData(ctx context.Context, req *pb.WebhookDataRequest) (*pb.WebhookAndCiData, error)
4849
GetAllWebhookEventConfigForHost(ctx context.Context, req *pb.WebhookEventConfigRequest) (*pb.WebhookEventConfigResponse, error)
@@ -119,7 +120,11 @@ func (impl *GrpcHandlerImpl) AddRepo(ctx context.Context, req *pb.AddRepoRequest
119120
}
120121
}
121122

122-
gitCtx := git.BuildGitContext(ctx)
123+
cloningMode := git.CloningModeFull
124+
if req.GitMaterialList != nil || len(req.GitMaterialList) > 0 {
125+
cloningMode = req.GitMaterialList[0].GetCloningMode()
126+
}
127+
gitCtx := git.BuildGitContext(ctx).WithCloningMode(cloningMode)
123128

124129
_, err := impl.repositoryManager.AddRepo(gitCtx, gitMaterials)
125130
if err != nil {
@@ -133,7 +138,7 @@ func (impl *GrpcHandlerImpl) AddRepo(ctx context.Context, req *pb.AddRepoRequest
133138
// UpdateRepo updates GitMaterial
134139
func (impl *GrpcHandlerImpl) UpdateRepo(ctx context.Context, req *pb.GitMaterial) (
135140
*pb.Empty, error) {
136-
gitCtx := git.BuildGitContext(ctx)
141+
gitCtx := git.BuildGitContext(ctx).WithCloningMode(req.GetCloningMode())
137142

138143
// Mapping
139144
mappedGitMaterial := &sql.GitMaterial{
@@ -301,8 +306,6 @@ func (impl *GrpcHandlerImpl) GetHeadForPipelineMaterials(ctx context.Context, re
301306
func (impl *GrpcHandlerImpl) GetCommitMetadata(ctx context.Context, req *pb.CommitMetadataRequest) (
302307
*pb.GitCommit, error) {
303308

304-
gitCtx := git.BuildGitContext(ctx)
305-
306309
// Mapping req body
307310
mappedReq := &git.CommitMetadataRequest{
308311
PipelineMaterialId: int(req.PipelineMaterialId),
@@ -313,6 +316,7 @@ func (impl *GrpcHandlerImpl) GetCommitMetadata(ctx context.Context, req *pb.Comm
313316

314317
var gitCommit *git.GitCommitBase
315318
var err error
319+
gitCtx := git.BuildGitContext(ctx)
316320

317321
if len(req.GitTag) > 0 {
318322
gitCommit, err = impl.repositoryManager.GetCommitInfoForTag(gitCtx, mappedReq)
@@ -480,6 +484,24 @@ func (impl *GrpcHandlerImpl) ReloadMaterial(ctx context.Context, req *pb.ReloadM
480484
}, nil
481485
}
482486

487+
func (impl *GrpcHandlerImpl) ReloadMaterials(ctx context.Context, req *pb.ReloadMaterialsRequest) (
488+
*pb.GenericResponse, error) {
489+
for _, material := range req.GetReloadMaterials() {
490+
gitCtx := git.BuildGitContext(ctx).WithCloningMode(material.GetCloningMode())
491+
err := impl.repositoryManager.ResetRepo(gitCtx, int(material.MaterialId))
492+
if err != nil {
493+
impl.logger.Errorw("error while reloading material",
494+
"materialId", material.MaterialId,
495+
"err", err)
496+
497+
}
498+
}
499+
500+
return &pb.GenericResponse{
501+
Message: "reloaded",
502+
}, nil
503+
}
504+
483505
func (impl *GrpcHandlerImpl) GetChangesInRelease(ctx context.Context, req *pb.ReleaseChangeRequest) (
484506
*pb.GitChanges, error) {
485507

api/ReloadMaterialsDto.go

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package api
2+
3+
type ReloadMaterialsDto struct {
4+
ReloadMaterial []ReloadMaterialDto `json:"reloadMaterial"`
5+
}
6+
7+
type ReloadMaterialDto struct {
8+
AppId int `json:"appId"`
9+
GitmaterialId int `json:"gitMaterialId"`
10+
CloningMode string `json:"cloningMode"`
11+
}

api/RestHandler.go

+36-3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type RestHandler interface {
3838
GetCommitMetadataForPipelineMaterial(w http.ResponseWriter, r *http.Request)
3939
ReloadAllMaterial(w http.ResponseWriter, r *http.Request)
4040
ReloadMaterial(w http.ResponseWriter, r *http.Request)
41+
ReloadMaterials(w http.ResponseWriter, r *http.Request)
4142
GetChangesInRelease(w http.ResponseWriter, r *http.Request)
4243
GetCommitInfoForTag(w http.ResponseWriter, r *http.Request)
4344
RefreshGitMaterial(w http.ResponseWriter, r *http.Request)
@@ -116,9 +117,13 @@ func (handler RestHandlerImpl) SaveGitProvider(w http.ResponseWriter, r *http.Re
116117
func (handler RestHandlerImpl) AddRepo(w http.ResponseWriter, r *http.Request) {
117118
decoder := json.NewDecoder(r.Body)
118119

119-
gitCtx := git.BuildGitContext(r.Context())
120120
var Repo []*sql.GitMaterial
121121
err := decoder.Decode(&Repo)
122+
cloningMode := git.CloningModeFull
123+
if Repo != nil && len(Repo) > 0 {
124+
cloningMode = Repo[0].CloningMode
125+
}
126+
gitCtx := git.BuildGitContext(r.Context()).WithCloningMode(cloningMode)
122127
if err != nil {
123128
handler.logger.Error(err)
124129
handler.writeJsonResp(w, err, nil, http.StatusBadRequest)
@@ -135,9 +140,9 @@ func (handler RestHandlerImpl) AddRepo(w http.ResponseWriter, r *http.Request) {
135140

136141
func (handler RestHandlerImpl) UpdateRepo(w http.ResponseWriter, r *http.Request) {
137142
decoder := json.NewDecoder(r.Body)
138-
gitCtx := git.BuildGitContext(r.Context())
139143
var Repo *sql.GitMaterial
140144
err := decoder.Decode(&Repo)
145+
gitCtx := git.BuildGitContext(r.Context()).WithCloningMode(Repo.CloningMode)
141146
if err != nil {
142147
handler.logger.Error(err)
143148
handler.writeJsonResp(w, err, nil, http.StatusBadRequest)
@@ -180,6 +185,34 @@ func (handler RestHandlerImpl) ReloadAllMaterial(w http.ResponseWriter, r *http.
180185
handler.writeJsonResp(w, nil, "reloaded se logs for detail", http.StatusOK)
181186
}
182187

188+
func (handler RestHandlerImpl) ReloadMaterials(w http.ResponseWriter, r *http.Request) {
189+
decoder := json.NewDecoder(r.Body)
190+
var request ReloadMaterialsDto
191+
err := decoder.Decode(&request)
192+
193+
//materialId, err := strconv.Atoi(vars["materialId"])
194+
if err != nil {
195+
handler.logger.Error(err)
196+
handler.writeJsonResp(w, err, nil, http.StatusBadRequest)
197+
return
198+
}
199+
for _, materialReq := range request.ReloadMaterial {
200+
handler.logger.Infow("reload all pipelineMaterial request", "id", materialReq.GitmaterialId)
201+
gitCtx := git.BuildGitContext(r.Context()).WithCloningMode(materialReq.CloningMode)
202+
err = handler.repositoryManager.ResetRepo(gitCtx, materialReq.GitmaterialId)
203+
if err != nil {
204+
handler.logger.Errorw("error in reloading pipeline material", "err", err)
205+
//handler.writeJsonResp(w, err, nil, http.StatusInternalServerError)
206+
}
207+
}
208+
//TODO: handle in such a way that it can propagate which material weren't able to reload
209+
handler.writeJsonResp(w, nil, Response{
210+
Code: http.StatusOK,
211+
Status: http.StatusText(http.StatusOK),
212+
}, http.StatusOK)
213+
214+
}
215+
183216
func (handler RestHandlerImpl) ReloadMaterial(w http.ResponseWriter, r *http.Request) {
184217
vars := mux.Vars(r)
185218
gitCtx := git.BuildGitContext(r.Context())
@@ -238,7 +271,6 @@ func (handler RestHandlerImpl) GetHeadForPipelineMaterials(w http.ResponseWriter
238271

239272
func (handler RestHandlerImpl) GetCommitMetadata(w http.ResponseWriter, r *http.Request) {
240273
decoder := json.NewDecoder(r.Body)
241-
gitCtx := git.BuildGitContext(r.Context())
242274

243275
material := &git.CommitMetadataRequest{}
244276
err := decoder.Decode(material)
@@ -247,6 +279,7 @@ func (handler RestHandlerImpl) GetCommitMetadata(w http.ResponseWriter, r *http.
247279
handler.writeJsonResp(w, err, nil, http.StatusBadRequest)
248280
return
249281
}
282+
gitCtx := git.BuildGitContext(r.Context())
250283
handler.logger.Infow("commit detail request", "req", material)
251284
var commits *git.GitCommitBase
252285
if len(material.GitTag) > 0 {

api/Router.go

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func (r MuxRouter) Init() {
7777

7878
r.Router.Path("/admin/reload-all").HandlerFunc(r.restHandler.ReloadAllMaterial).Methods("POST")
7979
r.Router.Path("/admin/reload/{materialId}").HandlerFunc(r.restHandler.ReloadMaterial).Methods("POST")
80+
r.Router.Path("/admin/reload-multi/materials").HandlerFunc(r.restHandler.ReloadMaterials).Methods("POST")
8081

8182
r.Router.Path("/release/changes").HandlerFunc(r.restHandler.GetChangesInRelease).Methods("POST")
8283

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.20
55
require (
66
github.com/caarlos0/env v3.5.0+incompatible
77
github.com/devtron-labs/common-lib v0.0.18-0.20240520062828-c6c38c3f135e
8-
github.com/devtron-labs/protos v0.0.3-0.20240130061723-7b2e12ab0abb
8+
github.com/devtron-labs/protos v0.0.3-0.20240527113333-08a3be5ec6c1
99
github.com/gammazero/workerpool v0.0.0-20200206003619-019d125201ab
1010
github.com/go-git/go-git/v5 v5.11.0
1111
github.com/go-pg/pg v6.15.1+incompatible

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
2929
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3030
github.com/devtron-labs/common-lib v0.0.18-0.20240520062828-c6c38c3f135e h1:feRK1mshlcKh9/dV5sWUtZTsMEBV3perE/OjmnvulQg=
3131
github.com/devtron-labs/common-lib v0.0.18-0.20240520062828-c6c38c3f135e/go.mod h1:deAcJ5IjUjM6ozZQLJEgPWDUA0mKa632LBsKx8uM9TE=
32-
github.com/devtron-labs/protos v0.0.3-0.20240130061723-7b2e12ab0abb h1:CkfQQgZc950/hTPqtQSiHV2RmZgkBLGCzwR02FZYjAU=
33-
github.com/devtron-labs/protos v0.0.3-0.20240130061723-7b2e12ab0abb/go.mod h1:pjLjgoa1GzbkOkvbMyP4SAKsaiK7eG6GoQCNauG03JA=
32+
github.com/devtron-labs/protos v0.0.3-0.20240527113333-08a3be5ec6c1 h1:R6qVeFaayqstBSu4w+ipWQqJyMKDqBVV3a11qoA2IaM=
33+
github.com/devtron-labs/protos v0.0.3-0.20240527113333-08a3be5ec6c1/go.mod h1:ypUknVph8Ph4dxSlrFoouf7wLedQxHku2LQwgRrdgS4=
3434
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU=
3535
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
3636
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=

internals/Configuration.go

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ type Configuration struct {
2222
CommitStatsTimeoutInSec int `env:"COMMIT_STATS_TIMEOUT_IN_SEC" envDefault:"2"`
2323
EnableFileStats bool `env:"ENABLE_FILE_STATS" envDefault:"false"`
2424
GitHistoryCount int `env:"GIT_HISTORY_COUNT" envDefault:"15"`
25-
CloningMode string `env:"CLONING_MODE" envDefault:"FULL"`
2625
MinLimit int `env:"MIN_LIMIT_FOR_PVC" envDefault:"1"` // in MB
2726
UseGitCli bool `env:"USE_GIT_CLI" envDefault:"false"`
2827
AnalyticsDebug bool `env:"ANALYTICS_DEBUG" envDefault:"false"`

internals/sql/GitMaterial.go

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type GitMaterial struct {
4848
FetchStatus bool `json:"fetch_status"`
4949
LastFetchErrorCount int `json:"last_fetch_error_count"` //continues fetch error
5050
FetchErrorMessage string `json:"fetch_error_message"`
51+
CloningMode string `json:"cloning_mode" sql:"-"`
5152
FilterPattern []string `sql:"filter_pattern"`
5253
GitProvider *GitProvider
5354
CiPipelineMaterials []*CiPipelineMaterial

pkg/RepoManages.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/devtron-labs/git-sensor/pkg/git"
2727
_ "github.com/robfig/cron/v3"
2828
"go.uber.org/zap"
29+
"strings"
2930
)
3031

3132
type RepoManager interface {
@@ -195,8 +196,7 @@ func (impl RepoManagerImpl) updatePipelineMaterialCommit(gitCtx git.GitContext,
195196
continue
196197
}
197198

198-
gitCtx = gitCtx.WithCredentials(material.GitProvider.UserName, material.GitProvider.Password).
199-
WithCloningMode(impl.configuration.CloningMode)
199+
gitCtx = gitCtx.WithCredentials(material.GitProvider.UserName, material.GitProvider.Password)
200200

201201
fetchCount := impl.configuration.GitHistoryCount
202202
var repository *git.GitRepository
@@ -351,8 +351,7 @@ func (impl RepoManagerImpl) checkoutMaterial(gitCtx git.GitContext, material *sq
351351
return material, nil
352352
}
353353

354-
gitCtx = gitCtx.WithCredentials(userName, password).
355-
WithCloningMode(impl.configuration.CloningMode)
354+
gitCtx = gitCtx.WithCredentials(userName, password)
356355

357356
checkoutPath, _, _, err := impl.repositoryManager.GetCheckoutLocationFromGitUrl(material, gitCtx.CloningMode)
358357
if err != nil {
@@ -638,8 +637,7 @@ func (impl RepoManagerImpl) GetLatestCommitForBranch(gitCtx git.GitContext, pipe
638637

639638
userName, password, err := git.GetUserNamePassword(gitMaterial.GitProvider)
640639

641-
gitCtx = gitCtx.WithCredentials(userName, password).
642-
WithCloningMode(impl.configuration.CloningMode)
640+
gitCtx = gitCtx.WithCredentials(userName, password)
643641

644642
updated, repo, err := impl.repositoryManager.Fetch(gitCtx, gitMaterial.Url, gitMaterial.CheckoutLocation)
645643
if !updated {
@@ -707,8 +705,7 @@ func (impl RepoManagerImpl) GetCommitMetadataForPipelineMaterial(gitCtx git.GitC
707705
return nil, err
708706
}
709707

710-
gitCtx = gitCtx.WithCredentials(gitMaterial.GitProvider.UserName, gitMaterial.GitProvider.Password).
711-
WithCloningMode(impl.configuration.CloningMode)
708+
gitCtx = gitCtx.WithCredentials(gitMaterial.GitProvider.UserName, gitMaterial.GitProvider.Password)
712709
// validate checkout status of gitMaterial
713710
if !gitMaterial.CheckoutStatus {
714711
impl.logger.Errorw("checkout not success", "gitMaterialId", gitMaterialId)
@@ -725,6 +722,10 @@ func (impl RepoManagerImpl) GetCommitMetadataForPipelineMaterial(gitCtx git.GitC
725722
var repository *git.GitRepository
726723
commits, err := impl.repositoryManager.ChangesSinceByRepository(gitCtx, repository, branchName, "", gitHash, 1, gitMaterial.CheckoutLocation, true)
727724
if err != nil {
725+
if strings.Contains(err.Error(), git.NO_COMMIT_CUSTOM_ERROR_MESSAGE) {
726+
impl.logger.Warnw("No commit found for given hash", "hash", gitHash, "branchName", branchName)
727+
return nil, nil
728+
}
728729
impl.logger.Errorw("error while fetching commit info", "pipelineMaterialId", pipelineMaterialId, "gitHash", gitHash, "err", err)
729730
return nil, err
730731
}
@@ -763,8 +764,7 @@ func (impl RepoManagerImpl) GetReleaseChanges(gitCtx git.GitContext, request *Re
763764
impl.locker.ReturnLocker(gitMaterial.Id)
764765
}()
765766

766-
gitCtx = gitCtx.WithCredentials(gitMaterial.GitProvider.UserName, gitMaterial.GitProvider.Password).
767-
WithCloningMode(impl.configuration.CloningMode)
767+
gitCtx = gitCtx.WithCredentials(gitMaterial.GitProvider.UserName, gitMaterial.GitProvider.Password)
768768

769769
gitChanges, err := impl.repositoryManagerAnalytics.ChangesSinceByRepositoryForAnalytics(gitCtx, gitMaterial.CheckoutLocation, request.OldCommit, request.NewCommit)
770770
if err != nil {

pkg/git/GitBaseManager.go

+25-4
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ type GitManagerBase interface {
5757
Checkout(gitCtx GitContext, rootDir, branch string) (response, errMsg string, err error)
5858
// ConfigureSshCommand configures ssh in git repo
5959
ConfigureSshCommand(gitCtx GitContext, rootDir string, sshPrivateKeyPath string) (response, errMsg string, err error)
60-
// FetchDiffStatBetweenCommits returns the file stats reponse on executing git action
61-
FetchDiffStatBetweenCommits(gitCtx GitContext, oldHash string, newHash string, rootDir string) (FileStats, error)
60+
// FetchDiffStatBetweenCommitsNameOnly returns the list of files changed in reponse on executing git action
61+
FetchDiffStatBetweenCommitsNameOnly(gitCtx GitContext, oldHash string, newHash string, rootDir string) (FileStats, error)
62+
// FetchDiffStatBetweenCommitsWithNumstat returns the file stats reponse on executing git action
63+
FetchDiffStatBetweenCommitsWithNumstat(gitCtx GitContext, oldHash string, newHash string, rootDir string) (FileStats, error)
6264
// LogMergeBase get the commit diff between using a merge base strategy
6365
LogMergeBase(gitCtx GitContext, rootDir, from string, to string) ([]*Commit, error)
6466
ExecuteCustomCommand(gitContext GitContext, name string, arg ...string) (response, errMsg string, err error)
@@ -287,7 +289,26 @@ func GetBranchReference(branch string) (string, string) {
287289
return branch, branchRef
288290
}
289291

290-
func (impl *GitManagerBaseImpl) FetchDiffStatBetweenCommits(gitCtx GitContext, oldHash string, newHash string, rootDir string) (FileStats, error) {
292+
func (impl *GitManagerBaseImpl) FetchDiffStatBetweenCommitsNameOnly(gitCtx GitContext, oldHash string, newHash string, rootDir string) (FileStats, error) {
293+
impl.logger.Debugw("git", "-C", rootDir, "diff", "--name-only", oldHash, newHash)
294+
295+
if newHash == "" {
296+
newHash = oldHash
297+
oldHash = oldHash + "^"
298+
}
299+
cmd, cancel := impl.createCmdWithContext(gitCtx, "git", "-C", rootDir, "diff", "--name-only", oldHash, newHash)
300+
defer cancel()
301+
302+
output, errMsg, err := impl.runCommandWithCred(cmd, gitCtx.Username, gitCtx.Password)
303+
impl.logger.Debugw("root", rootDir, "opt", output, "errMsg", errMsg, "error", err)
304+
if err != nil || len(errMsg) > 0 {
305+
impl.logger.Errorw("error in fetching fileStat diff btw commits: ", "oldHash", oldHash, "newHash", newHash, "checkoutPath", rootDir, "errorMsg", errMsg, "err", err)
306+
return nil, err
307+
}
308+
return processFileStatOutputNameOnly(output)
309+
}
310+
311+
func (impl *GitManagerBaseImpl) FetchDiffStatBetweenCommitsWithNumstat(gitCtx GitContext, oldHash string, newHash string, rootDir string) (FileStats, error) {
291312
impl.logger.Debugw("git", "-C", rootDir, "diff", "--numstat", oldHash, newHash)
292313

293314
if newHash == "" {
@@ -303,7 +324,7 @@ func (impl *GitManagerBaseImpl) FetchDiffStatBetweenCommits(gitCtx GitContext, o
303324
impl.logger.Errorw("error in fetching fileStat diff btw commits: ", "oldHash", oldHash, "newHash", newHash, "checkoutPath", rootDir, "errorMsg", errMsg, "err", err)
304325
return nil, err
305326
}
306-
return getFileStat(output)
327+
return processFileStatOutputWithNumstat(output)
307328
}
308329

309330
func (impl *GitManagerBaseImpl) createCmdWithContext(ctx GitContext, name string, arg ...string) (*exec.Cmd, context.CancelFunc) {

pkg/git/GitCliManager.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package git
1818

1919
import (
20+
"errors"
2021
"go.uber.org/zap"
2122
"gopkg.in/src-d/go-billy.v4/osfs"
2223
"os"
@@ -125,6 +126,9 @@ func (impl *GitCliManagerImpl) GetCommits(gitCtx GitContext, branchRef string, b
125126
output, errMsg, err := impl.GitManagerBase.ExecuteCustomCommand(gitCtx, "git", cmdArgs...)
126127
impl.logger.Debugw("root", rootDir, "opt", output, "errMsg", errMsg, "error", err)
127128
if err != nil {
129+
if strings.Contains(output, NO_COMMIT_GIT_ERROR_MESSAGE) {
130+
return nil, errors.New(NO_COMMIT_CUSTOM_ERROR_MESSAGE)
131+
}
128132
return nil, err
129133
}
130134
commits, err := impl.processGitLogOutput(output)
@@ -162,7 +166,7 @@ func (impl *GitCliManagerImpl) GitShow(gitCtx GitContext, rootDir string, hash s
162166

163167
func (impl *GitCliManagerImpl) GetCommitStats(gitCtx GitContext, commit GitCommit, checkoutPath string) (FileStats, error) {
164168
gitCommit := commit.GetCommit()
165-
return impl.FetchDiffStatBetweenCommits(gitCtx, gitCommit.Commit, "", checkoutPath)
169+
return impl.FetchDiffStatBetweenCommitsNameOnly(gitCtx, gitCommit.Commit, "", checkoutPath)
166170
}
167171

168172
func (impl *GitCliManagerImpl) processGitLogOutput(out string) ([]GitCommit, error) {

pkg/git/GitContextUtils.go

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ func (gitCtx GitContext) WithTimeout(timeoutSeconds int) (GitContext, context.Ca
4747
}
4848

4949
func (gitCtx GitContext) WithCloningMode(CloningMode string) GitContext {
50+
if CloningMode == "" {
51+
CloningMode = CloningModeFull
52+
}
5053
gitCtx.CloningMode = CloningMode
5154
return gitCtx
5255
}

pkg/git/GoGitSDKManager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (impl *GoGitSDKManagerImpl) Init(gitCtx GitContext, rootDir string, remoteU
140140

141141
func (impl *GoGitSDKManagerImpl) GetCommitStats(gitCtx GitContext, commit GitCommit, checkoutPath string) (FileStats, error) {
142142
if IsRepoShallowCloned(checkoutPath) {
143-
return impl.GitManagerBase.FetchDiffStatBetweenCommits(gitCtx, commit.GetCommit().Commit, "", checkoutPath)
143+
return impl.GitManagerBase.FetchDiffStatBetweenCommitsNameOnly(gitCtx, commit.GetCommit().Commit, "", checkoutPath)
144144
}
145145
gitCommit := commit.(*GitCommitGoGit)
146146

0 commit comments

Comments
 (0)