MCPcopy Create free account
hub / github.com/ByConity/ByConity / processCommit

Function processCommit

programs/git-import/git-import.cpp:1052–1114  ·  view source on GitHub ↗

Process the "git show" result for a single commit. Append the result to tables. */

Source from the content-addressed store, hash-verified

1050/** Process the "git show" result for a single commit. Append the result to tables.
1051 */
1052void processCommit(
1053 ReadBuffer & in,
1054 const Options & options,
1055 size_t commit_num,
1056 size_t total_commits,
1057 std::string hash,
1058 Snapshot & snapshot,
1059 DiffHashes & diff_hashes,
1060 ResultWriter & result)
1061{
1062 Commit commit;
1063 commit.hash = hash;
1064
1065 time_t commit_time;
1066 readText(commit_time, in);
1067 commit.time = LocalDateTime(commit_time);
1068 assertChar('\0', in);
1069 readNullTerminated(commit.author, in);
1070 std::string parent_hash;
1071 readNullTerminated(parent_hash, in);
1072 readNullTerminated(commit.message, in);
1073
1074 if (options.skip_commits_with_messages && re2::RE2::PartialMatch(commit.message, *options.skip_commits_with_messages))
1075 return;
1076
1077 std::string message_to_print = commit.message;
1078 std::replace_if(message_to_print.begin(), message_to_print.end(), [](char c){ return std::iscntrl(c); }, ' ');
1079
1080 std::cerr << fmt::format("{}% {} {} {}\n",
1081 commit_num * 100 / total_commits, toString(commit.time), hash, message_to_print);
1082
1083 if (options.skip_commits_without_parents && commit_num != 0 && parent_hash.empty())
1084 {
1085 std::cerr << "Warning: skipping commit without parents\n";
1086 return;
1087 }
1088
1089 if (!in.eof())
1090 assertChar('\n', in);
1091
1092 CommitDiff file_changes;
1093 processFileChanges(in, options, commit, file_changes);
1094
1095 if (!in.eof())
1096 {
1097 assertChar('\n', in);
1098 processDiffs(in, commit_num != 0 ? options.diff_size_limit : std::nullopt, commit, file_changes);
1099 }
1100
1101 /// Skip commits with too large diffs.
1102 if (options.diff_size_limit && commit_num != 0 && commit.lines_added + commit.lines_deleted > *options.diff_size_limit)
1103 return;
1104
1105 /// Calculate hash of diff and skip duplicates
1106 if (options.skip_commits_with_duplicate_diffs && !diff_hashes.insert(diffHash(file_changes)).second)
1107 return;
1108
1109 /// Update snapshot and blame info

Callers 1

processLogFunction · 0.85

Calls 15

LocalDateTimeClass · 0.85
assertCharFunction · 0.85
processFileChangesFunction · 0.85
processDiffsFunction · 0.85
diffHashFunction · 0.85
updateSnapshotFunction · 0.85
appendCommitMethod · 0.80
readTextFunction · 0.50
readNullTerminatedFunction · 0.50
toStringFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected