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

Function processCommit

programs/git-import/git-import.cpp:1059–1121  ·  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

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

Tested by

no test coverage detected