Skip to content

Commit 203b6a2

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

File tree

7 files changed

+36
-14
lines changed

7 files changed

+36
-14
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

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

scripts/importGit.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ set -o errexit -o pipefail
1414
# Overrideable Defaults
1515
SOURCE_DIRECTORY=${SOURCE_DIRECTORY:-"source"} # Get the source repository directory (defaults to "source")
1616
IMPORT_DIRECTORY=${IMPORT_DIRECTORY:-"import"}
17-
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT=${IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT:-"full"} # Select how to import git log data. Options: "none", "aggregated", "full". Default="full".
17+
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT=${IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT:-"plugin"} # Select how to import git log data. Options: "none", "aggregated", "full" and "plugin". Default="plugin".
1818

1919
# Default and initial values for command line options
2020
source="${SOURCE_DIRECTORY}"
2121

2222
# Read command line options
2323
USAGE="importGit: Usage: $0 [--source <directory containing git repositories>(default=source)]"
24-
while [[ $# -gt 0 ]]; do
24+
while [ "$#" -gt "0" ]; do
2525
key="$1"
2626
case $key in
2727
--source)
@@ -120,21 +120,21 @@ importAggregatedGitLog() {
120120
time execute_cypher "${GIT_LOG_CYPHER_DIR}/Import_aggregated_git_log_csv_data.cypher" "${@}"
121121
}
122122

123-
commonPostGitLogImport() {
123+
commonPostGitImport() {
124124
echo "importGit: Creating relationships to nodes with matching file names..."
125125
execute_cypher "${GIT_LOG_CYPHER_DIR}/Add_RESOLVES_TO_relationships_to_git_files_for_Java.cypher"
126126
execute_cypher "${GIT_LOG_CYPHER_DIR}/Add_RESOLVES_TO_relationships_to_git_files_for_Typescript.cypher"
127127
}
128128

129-
postGitLogImport() {
130-
commonPostGitLogImport
129+
postGitImport() {
130+
commonPostGitImport
131131

132132
echo "importGit: Add numberOfGitCommits property to nodes with matching file names..."
133133
execute_cypher "${GIT_LOG_CYPHER_DIR}/Set_number_of_git_commits.cypher"
134134
}
135135

136136
postAggregatedGitLogImport() {
137-
commonPostGitLogImport
137+
commonPostGitImport
138138

139139
echo "importGit: Add numberOfGitCommits property to nodes with matching file names..."
140140
execute_cypher "${GIT_LOG_CYPHER_DIR}/Set_number_of_aggregated_git_commits.cypher"
@@ -146,8 +146,8 @@ mkdir -p "${IMPORT_DIRECTORY}"
146146
# Internal constants
147147
NEO4J_FULL_IMPORT_DIRECTORY=$(cd "${IMPORT_DIRECTORY}"; pwd)
148148

149-
# Skip import when IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT = "none"
150-
if [[ ! ${IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT} == "none" ]]; then
149+
# Skip import if it is switched off ("none") or if it already taken care of by a plugin ("plugin"), which is the default.
150+
if [ ! "${IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT}" = "none" ] && [ ! "${IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT}" = "plugin" ]; then
151151

152152
existing_data_has_been_deleted=false
153153

@@ -163,7 +163,7 @@ if [[ ! ${IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT} == "none" ]]; then
163163

164164
create_git_repository_node "${full_repository_path}"
165165

166-
if [[ ${IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT} == "aggregated" ]]; then
166+
if [ "${IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT}" = "aggregated" ]; then
167167
# Import pre-aggregated git log data (no single commits) when IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT = "aggregated"
168168
(cd "${repository}" && source "${SCRIPTS_DIR}/createAggregatedGitLogCsv.sh" "${NEO4J_FULL_IMPORT_DIRECTORY}/aggregatedGitLog.csv")
169169
importAggregatedGitLog "git_repository_absolute_directory_name=${full_repository_path}"
@@ -172,9 +172,14 @@ if [[ ! ${IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT} == "none" ]]; then
172172
# Import git log data with every commit when IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT = "full" (default)
173173
(cd "${repository}" && source "${SCRIPTS_DIR}/createGitLogCsv.sh" "${NEO4J_FULL_IMPORT_DIRECTORY}/gitLog.csv")
174174
importGitLog "git_repository_absolute_directory_name=${full_repository_path}"
175-
postGitLogImport
175+
postGitImport
176176
fi
177177
done
178178
else
179179
echo "importGit: Skipped git import because of IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT=${IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT}"
180180
fi
181+
182+
# Even if the data had already been imported by a plugin, the post data enrichment still needs to be done.
183+
if [ "${IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT}" = "plugin" ]; then
184+
postGitImport
185+
fi

0 commit comments

Comments
 (0)