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