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
+ ,(git_file :Directory ) AS isDirectory
10
+ WITH *
11
+ ,rtrim (split (gitFileName , gitFileNameWithoutPath )[0 ], '/' ) AS gitDirectoryPath
12
+ WITH git_repository .name AS gitRepositoryName
13
+ ,gitDirectoryPath
14
+ ,coalesce (nullif (split (gitDirectoryPath , '/' )[- 2 ],'' ), 'root' ) AS directoryParentName
15
+ ,coalesce (nullif (split (gitDirectoryPath , '/' )[- 1 ],'' ), 'root' ) AS directoryName
16
+ ,size (split (gitDirectoryPath , '/' )) AS pathLength
17
+ ,count (DISTINCT gitFileName ) AS fileCount
18
+ ,count (distinct git_commit .sha ) AS commitCount
19
+ ,count (distinct git_commit .author ) AS authorCount
20
+ // Debugging
21
+ // ,collect(distinct git_commit.sha)[0..9] AS gitCommitExamples
22
+ // ,collect(distinct git_commit.author)[0..9] AS gitCommitAuthorExamples
23
+ // ,collect(git_file)[0..4] AS gitFileExamples
24
+ // ,collect(gitFileName) AS gitFileNameExamples
25
+ // ,collect(gitFileNameWithoutPath) AS gitFileNameWithoutPathExamples
26
+ WHERE fileCount > 1 // Filter out single files and directories with only one file
27
+ RETURN gitRepositoryName
28
+ ,gitDirectoryPath
29
+ ,directoryParentName
30
+ ,directoryName
31
+ ,pathLength
32
+ ,fileCount
33
+ ,commitCount
34
+ ,authorCount
35
+ // Debugging
36
+ // ,gitFileExamples
37
+ // ,gitFileNameExamples
38
+ // ,gitFileNameWithoutPathExamples
39
+ ORDER BY gitDirectoryPath ASC
0 commit comments