Skip to content

Commit df9e2fd

Browse files
authored
DEVPROD-26851: add logging for git include worktrees (#9789)
1 parent 98ebc16 commit df9e2fd

1 file changed

Lines changed: 46 additions & 12 deletions

File tree

model/project_parser.go

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"path/filepath"
88
"reflect"
9+
"runtime/debug"
910
"slices"
1011
"strings"
1112
"sync"
@@ -1052,6 +1053,31 @@ func setupParallelGitIncludeDirs(ctx context.Context, modules ModuleList, includ
10521053
}
10531054
}
10541055

1056+
dirsAsStringMaps := struct {
1057+
ClonesForOwnerRepo map[string]string `json:"clones_for_owner_repo"`
1058+
WorktreesForOwnerRepo map[string][]string `json:"worktrees_for_owner_repo"`
1059+
}{
1060+
ClonesForOwnerRepo: make(map[string]string),
1061+
WorktreesForOwnerRepo: make(map[string][]string),
1062+
}
1063+
for ownerRepo, cloneDir := range dirs.clonesForOwnerRepo {
1064+
dirsAsStringMaps.ClonesForOwnerRepo[fmt.Sprintf("%s-%s", ownerRepo.owner, ownerRepo.repo)] = cloneDir
1065+
}
1066+
for ownerRepo, worktreeDirs := range dirs.worktreesForOwnerRepo {
1067+
dirsAsStringMaps.WorktreesForOwnerRepo[fmt.Sprintf("%s-%s", ownerRepo.owner, ownerRepo.repo)] = worktreeDirs
1068+
}
1069+
1070+
grip.Info(message.Fields{
1071+
"message": "set up git worktrees for parallel includes",
1072+
"owner": opts.Ref.Owner,
1073+
"repo": opts.Ref.Repo,
1074+
"project_id": opts.Ref.Id,
1075+
"project_identifier": opts.Ref.Identifier,
1076+
"revision": opts.Revision,
1077+
"errors": catcher.Resolve(),
1078+
"git_include_dirs": dirsAsStringMaps,
1079+
})
1080+
10551081
return dirs, catcher.Resolve()
10561082
}
10571083

@@ -1166,12 +1192,16 @@ func retrieveFile(ctx context.Context, opts GetProjectOpts) ([]byte, error) {
11661192
// sufficient confidence that worktrees are set up properly for
11671193
// included files.
11681194
grip.Warning(message.Fields{
1169-
"message": "including file but worktree is not set, will not use git",
1170-
"owner": opts.Ref.Owner,
1171-
"repo": opts.Ref.Repo,
1172-
"revision": opts.Revision,
1173-
"file_name": opts.RemotePath,
1174-
"ticket": "DEVPROD-26851",
1195+
"message": "including file but worktree is not set, will not use git",
1196+
"project_id": opts.Ref.Id,
1197+
"project_identifier": opts.Ref.Identifier,
1198+
"owner": opts.Ref.Owner,
1199+
"repo": opts.Ref.Repo,
1200+
"revision": opts.Revision,
1201+
"file_name": opts.RemotePath,
1202+
"read_file_from": opts.ReadFileFrom,
1203+
"stack": string(debug.Stack()),
1204+
"ticket": "DEVPROD-26851",
11751205
})
11761206
useGit = false
11771207
}
@@ -1283,12 +1313,16 @@ func getFileForPatchDiff(ctx context.Context, opts GetProjectOpts) ([]byte, erro
12831313
// TODO (DEVPROD-26851): remove this condition once we have sufficient
12841314
// confidence that worktrees are set up properly for included files.
12851315
grip.Warning(message.Fields{
1286-
"message": "including file but worktree is not set, will not use git",
1287-
"owner": opts.Ref.Owner,
1288-
"repo": opts.Ref.Repo,
1289-
"revision": opts.Revision,
1290-
"file_name": opts.RemotePath,
1291-
"ticket": "DEVPROD-26851",
1316+
"message": "including file but worktree is not set, will not use git",
1317+
"project_id": opts.Ref.Id,
1318+
"project_identifier": opts.Ref.Identifier,
1319+
"owner": opts.Ref.Owner,
1320+
"repo": opts.Ref.Repo,
1321+
"revision": opts.Revision,
1322+
"file_name": opts.RemotePath,
1323+
"read_file_from": opts.ReadFileFrom,
1324+
"stack": string(debug.Stack()),
1325+
"ticket": "DEVPROD-26851",
12921326
})
12931327
useGit = false
12941328
}

0 commit comments

Comments
 (0)