Skip to content

Commit 417da21

Browse files
committed
Use git plugin from kontext-e/jqassistant-plugins
1 parent 00078c4 commit 417da21

11 files changed

+62
-18
lines changed

.github/workflows/java-code-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ jobs:
131131
env:
132132
NEO4J_INITIAL_PASSWORD: ${{ secrets.NEO4J_INITIAL_PASSWORD }}
133133
ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION: "true"
134-
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT: "full" # Options: "none", "aggregated", "full"
134+
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT: "" # Options: "none", "aggregated", "full". default = "plugin" or ""
135135
run: |
136136
./../../scripts/analysis/analyze.sh
137137

.github/workflows/typescript-code-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ jobs:
140140
env:
141141
NEO4J_INITIAL_PASSWORD: ${{ secrets.NEO4J_INITIAL_PASSWORD }}
142142
ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION: "true"
143-
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT: "full" # Options: "none", "aggregated", "full"
143+
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT: "" # Options: "none", "aggregated", "full". default = "plugin" or ""
144144
run: |
145145
./../../scripts/analysis/analyze.sh
146146

COMMANDS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ The optional parameter `--source directory-path-to-the-source-folder-containing-
300300

301301
#### Environment Variable
302302

303-
- `IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT` supports the values `none`, `aggregated` and `full` (default). With it, you can switch off git import (`none`), import aggregated data for a smaller memory footprint (`aggregated`) or import all git commits and the files that where changed with them (`full`=default) .
303+
- `IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT` supports the values `none`, `aggregated`, `full` and `plugin` (default). With it, you can switch off git import (`none`), import aggregated data for a smaller memory footprint (`aggregated`), import all commits with git log in a simple way (`full`) or let a plugin take care of git data (`plugin`= `""`=default) .
304304

305305
#### Resolving git files to code files
306306

cypher/GitLog/Add_RESOLVES_TO_relationships_to_git_files_for_Java.cypher

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ MATCH (code_file:File&!Git)
77
WHERE NOT EXISTS { (code_file)-[:RESOLVES_TO]->(other_file:File&!Git) } // only original nodes, no duplicates
88
WITH code_file, replace(code_file.fileName, '.class', '.java') AS codeFileName
99
MATCH (git_file:File&Git)
10-
WHERE git_file.fileName ENDS WITH codeFileName
10+
WITH *
11+
,git_file
12+
,coalesce(git_file.fileName, git_file.relativePath) AS gitFileName
13+
WHERE gitFileName ENDS WITH codeFileName
1114
MERGE (git_file)-[:RESOLVES_TO]->(code_file)
1215
SET git_file.resolved = true
1316
RETURN count(DISTINCT codeFileName) AS numberOfCodeFiles
14-
,collect(DISTINCT codeFileName + ' <-> ' + git_file.fileName + '\n')[0..4] AS examples
17+
,collect(DISTINCT codeFileName + ' <-> ' + gitFileName + '\n')[0..4] AS examples

cypher/GitLog/Add_RESOLVES_TO_relationships_to_git_files_for_Typescript.cypher

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ MATCH (code_file:File&!Git)
77
WHERE NOT EXISTS { (code_file)-[:RESOLVES_TO]->(other_file:File&!Git) } // only original nodes, no duplicates
88
WITH code_file, code_file.absoluteFileName AS codeFileName
99
MATCH (git_file:File&Git)
10-
WHERE codeFileName ENDS WITH git_file.fileName
10+
WITH *
11+
,git_file
12+
,coalesce(git_file.fileName, git_file.relativePath) AS gitFileName
13+
WHERE codeFileName ENDS WITH gitFileName
1114
MERGE (git_file)-[:RESOLVES_TO]->(code_file)
1215
SET git_file.resolved = true
1316
RETURN count(DISTINCT codeFileName) AS numberOfCodeFiles
14-
,collect(DISTINCT codeFileName + ' <-> ' + git_file.fileName + '\n')[0..4] AS examples
17+
,collect(DISTINCT codeFileName + ' <-> ' + gitFileName + '\n')[0..4] AS examples

cypher/GitLog/Set_number_of_git_commits.cypher renamed to cypher/GitLog/Set_number_of_git_log_commits.cypher

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ MATCH (code_file:File&!Git)<-[:RESOLVES_TO]-(git_file:File&Git)
44
MATCH (git_file)<-[:CONTAINS_CHANGED]-(git_commit:Git:Commit)
55
WITH code_file, count(DISTINCT git_commit.hash) AS numberOfGitCommits
66
SET code_file.numberOfGitCommits = numberOfGitCommits
7-
RETURN count(DISTINCT coalesce(code_file.absoluteFileName, code_file.fileName)) AS changedCodeFiles
7+
RETURN count(DISTINCT coalesce(code_file.absoluteFileName, code_file.fileName)) AS changedCodeFiles
8+
//,collect(DISTINCT coalesce(code_file.absoluteFileName, code_file.fileName))[0..4] AS examples
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Set numberOfGitCommits property on code File nodes when git commits (detected by the plugin) are present
2+
3+
MATCH (code_file:File&!Git)<-[:RESOLVES_TO]-(git_file:File&Git)
4+
MATCH (git_file)<-[]-(:Git&Change)<-[:CONTAINS_CHANGE]-(git_commit:Git&Commit)
5+
WITH code_file, count(DISTINCT git_commit.sha) AS numberOfGitCommits
6+
SET code_file.numberOfGitCommits = numberOfGitCommits
7+
RETURN count(DISTINCT coalesce(code_file.absoluteFileName, code_file.fileName)) AS changedCodeFiles
8+
//,collect(DISTINCT coalesce(code_file.absoluteFileName, code_file.fileName))[0..4] AS examples

scripts/configuration/template-neo4jv4-jqassistant.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ jqassistant:
3333
- group-id: org.jqassistant.plugin
3434
artifact-id: jqassistant-npm-plugin
3535
version: 2.0.0
36+
- group-id: de.kontext-e.jqassistant.plugin
37+
artifact-id: jqassistant.plugin.git
38+
version: 2.1.0
39+
40+
3641
# The store configuration
3742
store:
3843
# URI of the database to connect to. Supported URI schemes are 'file' for embedded databases and 'bolt' for connecting to a running Neo4j instance (3.x+), e.g.

scripts/configuration/template-neo4jv5-jqassistant.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ jqassistant:
3333
- group-id: org.jqassistant.plugin
3434
artifact-id: jqassistant-npm-plugin
3535
version: 2.0.0
36-
36+
- group-id: de.kontext-e.jqassistant.plugin
37+
artifact-id: jqassistant.plugin.git
38+
version: 2.1.0
39+
40+
3741
# The store configuration
3842
store:
3943
# URI of the database to connect to. Supported URI schemes are 'file' for embedded databases and 'bolt' for connecting to a running Neo4j instance (3.x+), e.g.

scripts/findPathsToScan.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ if [ -d "${SOURCE_DIRECTORY}" ] ; then
4040
if [ -n "${npmPackageJsonFiles}" ]; then
4141
directoriesAndFilesToScan="$(appendNonEmpty "${directoriesAndFilesToScan}")${npmPackageJsonFiles}"
4242
fi
43+
44+
# Scan git repositories in the artifacts directory
45+
if [ "${IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT}" = "" ] || [ "${IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT}" = "plugin" ] ; then
46+
gitDirectories="$(find "${SOURCE_DIRECTORY}" -type d -name ".git" -exec echo {} \; | tr '\n' ',' | sed 's/,$/\n/')"
47+
if [ -n "${gitDirectories}" ]; then
48+
directoriesAndFilesToScan="$(appendNonEmpty "${directoriesAndFilesToScan}")${gitDirectories}"
49+
fi
50+
fi
4351
else
4452
echo "findPathsToScan: Source directory ${SOURCE_DIRECTORY} doesn't exist and will therefore be skipped." >&2
4553
fi

0 commit comments

Comments
 (0)