Skip to content

Commit 8345fed

Browse files
committed
Add git operation info logs
1 parent 75b4daf commit 8345fed

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

pkg/externalrepo/git/git.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ func (r *gitRepository) fetchRemoteRepository(ctx context.Context) error {
10681068
ctx, span := tracer.Start(ctx, "gitRepository::fetchRemoteRepository", trace.WithAttributes())
10691069
defer span.End()
10701070
start := time.Now()
1071-
defer func() { klog.V(4).Infof("Fetching repository %q took %s", r.key.Name, time.Since(start)) }()
1071+
defer func() { klog.V(2).Infof("Fetching repository %q took %s", r.key.Name, time.Since(start)) }()
10721072

10731073
if ctx.Err() != nil {
10741074
return ctx.Err()
@@ -1227,7 +1227,8 @@ func (r *gitRepository) pushAndCleanup(ctx context.Context, ph *pushRefSpecBuild
12271227
return err
12281228
}
12291229

1230-
klog.Infof("pushing refs: %v", specs)
1230+
pushStart := time.Now()
1231+
klog.Infof("git push: repository=%q remote=%s refs=%v", r.key.Name, OriginName, specs)
12311232

12321233
if err := r.doGitWithAuth(ctx, func(auth transport.AuthMethod) error {
12331234
return r.repo.Push(&git.PushOptions{
@@ -1240,13 +1241,15 @@ func (r *gitRepository) pushAndCleanup(ctx context.Context, ph *pushRefSpecBuild
12401241
CABundle: r.caBundle,
12411242
})
12421243
}); err != nil {
1244+
klog.Infof("git push failed: repository=%q duration=%s error=%v", r.key.Name, time.Since(pushStart), err)
12431245
// TODO: This is a temporary solution until https://github.com/go-git/go-git/issues/1528 is fixed
12441246
if strings.Contains(err.Error(), "remote ref") &&
12451247
strings.Contains(err.Error(), "required to be") {
12461248
return conflictingRequiredRemoteRefError
12471249
}
12481250
return err
12491251
}
1252+
klog.Infof("git push completed: repository=%q duration=%s", r.key.Name, time.Since(pushStart))
12501253
return nil
12511254
}
12521255

0 commit comments

Comments
 (0)