1+ // List git file directories and the number of files they contain
2+
3+ MATCH (git_file :File &Git &! Repository )
4+ OPTIONAL MATCH (git_commit :Git &Commit )- [ : CONTAINS_CHANGE ] -> (git_change :Git &Change )- [ ] -> (git_file )
5+ OPTIONAL MATCH (git_repository :Git &Repository )- [ : HAS_FILE ] -> (git_file )
6+ WITH *
7+ ,git_file .relativePath AS gitFileName
8+ ,reverse (split (reverse (git_file .relativePath ),'/' )[0 ]) AS gitFileNameWithoutPath
9+ WITH *
10+ ,rtrim (split (gitFileName , gitFileNameWithoutPath )[0 ], '/' ) AS gitDirectoryPath
11+ WITH git_repository .name AS gitRepositoryName
12+ ,gitDirectoryPath
13+ ,coalesce (nullif (split (gitDirectoryPath , '/' )[- 2 ],'' ), 'root' ) AS directoryParentName
14+ ,coalesce (nullif (split (gitDirectoryPath , '/' )[- 1 ],'' ), 'root' ) AS directoryName
15+ ,size (split (gitDirectoryPath , '/' )) AS pathLength
16+ ,count (DISTINCT gitFileName ) AS fileCount
17+ ,count (distinct git_commit .sha ) AS commitCount
18+ ,count (distinct git_commit .author ) AS authorCount
19+ // Debugging
20+ // ,collect(distinct git_commit.sha)[0..9] AS gitCommitExamples
21+ // ,collect(distinct git_commit.author)[0..9] AS gitCommitAuthorExamples
22+ // ,collect(git_file)[0..4] AS gitFileExamples
23+ // ,collect(gitFileName) AS gitFileNameExamples
24+ // ,collect(gitFileNameWithoutPath) AS gitFileNameWithoutPathExamples
25+ WHERE fileCount > 1 // Filter out single files and directories with only one file
26+ RETURN gitRepositoryName
27+ ,gitDirectoryPath
28+ ,directoryParentName
29+ ,directoryName
30+ ,pathLength
31+ ,fileCount
32+ ,commitCount
33+ ,authorCount
34+ // Debugging
35+ // ,gitFileExamples
36+ // ,gitFileNameExamples
37+ // ,gitFileNameWithoutPathExamples
38+ ORDER BY gitDirectoryPath ASC
0 commit comments