@@ -78,17 +78,18 @@ echo "importGitLog: Creating ${OUTPUT_CSV_FILENAME} from git log..."
7878 cd " ${repository} " || exit
7979
8080 # Prints the header line of the CSV file with the names of the columns.
81- echo " hash,author,email,timestamp,timestamp_unix,message,filename" > " ${OUTPUT_CSV_FILENAME} "
81+ echo " hash,parent, author,email,timestamp,timestamp_unix,message,filename" > " ${OUTPUT_CSV_FILENAME} "
8282
8383 # Prints the git log in CSV format including the changed files.
8484 # Includes quoted strings, double quote escaping and supports commas in strings.
85- git log --no-merges --pretty=format:' %h,,,%an,,,%ae,,,%aI,,,%ct,,,%s' --name-only | \
86- awk ' BEGIN { COMMA=",";QUOTE="\"" } /^ / { split($0, a, ",,,"); gsub(/^ /, "", a[1]); gsub(/"/, "\"\"", a[2 ]); gsub(/"/, "\"\"", a[3 ]); gsub(/"/, "\"\"", a[6 ]); gsub(/\\/, " ", a[6 ]); commit=a[1] COMMA QUOTE a[2] QUOTE COMMA QUOTE a[3] QUOTE COMMA a[4] COMMA a[5] COMMA QUOTE a[6 ] QUOTE } NF && !/^\ / { print commit ",\""$0"\"" }' | \
85+ git log --no-merges --pretty=format:' %h,,,%p,,,% an,,,%ae,,,%aI,,,%ct,,,%s' --name-only | \
86+ awk ' BEGIN { COMMA=",";QUOTE="\"" } /^ / { split($0, a, ",,,"); gsub(/^ /, "", a[1]); gsub(/"/, "\"\"", a[3 ]); gsub(/"/, "\"\"", a[4 ]); gsub(/"/, "\"\"", a[7 ]); gsub(/\\/, " ", a[7 ]); commit=a[1] COMMA a[2] COMMA QUOTE a[3] QUOTE COMMA QUOTE a[4] QUOTE COMMA a[5] COMMA a[6] COMMA QUOTE a[7 ] QUOTE } NF && !/^\ / { print commit ",\""$0"\"" }' | \
8787 grep -v -F ' [bot]' >> " ${OUTPUT_CSV_FILENAME} "
8888 # Explanation:
8989 #
9090 # - --no-merges: Excludes merge commits from the log.
9191 # - %h: Abbreviated commit hash
92+ # - %p: Abbreviated parent commit hash
9293 # - %an: Author name
9394 # - %ae: Author email
9495 # - %aI: Author date, ISO 8601 format
@@ -125,6 +126,7 @@ GIT_LOG_CYPHER_DIR="${CYPHER_DIR}/GitLog"
125126echo " importGitLog: Prepare import by creating indexes..."
126127execute_cypher " ${GIT_LOG_CYPHER_DIR} /Index_author_name.cypher"
127128execute_cypher " ${GIT_LOG_CYPHER_DIR} /Index_commit_hash.cypher"
129+ execute_cypher " ${GIT_LOG_CYPHER_DIR} /Index_commit_parent.cypher"
128130execute_cypher " ${GIT_LOG_CYPHER_DIR} /Index_file_name.cypher"
129131
130132echo " importGitLog: Deleting all existing git data in the Graph..."
@@ -133,7 +135,10 @@ execute_cypher "${GIT_LOG_CYPHER_DIR}/Delete_git_log_data.cypher"
133135echo " importGitLog: Importing git log data into the Graph..."
134136time execute_cypher " ${GIT_LOG_CYPHER_DIR} /Import_git_log_csv_data.cypher"
135137
136- echo " importGitLog: Creating connections to nodes with matching file names..."
138+ echo " importGitLog: Creating relationships for parent commits..."
139+ execute_cypher " ${GIT_LOG_CYPHER_DIR} /Add_HAS_PARENT_relationships_to_commits.cypher"
140+
141+ echo " importGitLog: Creating relationships to nodes with matching file names..."
137142execute_cypher " ${GIT_LOG_CYPHER_DIR} /Add_RESOLVES_TO_relationships_to_git_files_for_Java.cypher"
138143execute_cypher " ${GIT_LOG_CYPHER_DIR} /Add_RESOLVES_TO_relationships_to_git_files_for_Typescript.cypher"
139144execute_cypher " ${GIT_LOG_CYPHER_DIR} /Set_number_of_git_commits.cypher"
0 commit comments