MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / commits

Method commits

src/plugins/chat/copilot.cpp:182–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182void Copilot::commits()
183{
184 QProcess process;
185 process.setProgram("git");
186 process.setArguments(QStringList() << "diff");
187 auto &ctx = dpfInstance.serviceContext();
188 ProjectService *projectService = ctx.service<ProjectService>(ProjectService::name());
189 auto prjInfo = projectService->getActiveProjectInfo();
190 auto workingDirectory = prjInfo.workspaceFolder();
191 process.setWorkingDirectory(workingDirectory);
192
193 connect(&process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this, &process](int exitCode, QProcess::ExitStatus exitStatus) {
194 Q_UNUSED(exitStatus)
195 if (exitCode != 0)
196 return;
197
198 auto diff = QString::fromUtf8(process.read(20000));
199 QString prompt = "diff: ```%1```\n\n"
200 "You always analyze the git diff provided, detect changes, and generate succinct yet comprehensive commit messages. for the user step-by-step:\n1. You first parse the git diff to understand the changes made: additions, deletions, modifications, or renaming.\n2. Identify the components or modules that the changes are relating to.\n3. Understand the nature of changes: bug fixes, functionality enhancements, code optimization, documentation, etc.\n4. You highlight the primary updates without neglecting any minor alterations.\n5. Choose a commit type according to the primary updates.\n6. Organize these changes into an accurate, concise and informative commit message less than 20 words.\nYou should only reply a one-line commit message less than 20 words!!!";
201 if (commitsLocale == Zh)
202 prompt.append("\nPlease answer by Chineses");
203 ChatManager::instance()->requestAsync(prompt.arg(diff));
204 switchToChatPage();
205 });
206
207 process.start();
208 process.waitForFinished();
209}
210
211void Copilot::switchToChatPage()
212{

Callers

nothing calls this directly

Calls 10

connectFunction · 0.85
requestAsyncMethod · 0.80
nameFunction · 0.50
setProgramMethod · 0.45
setArgumentsMethod · 0.45
getActiveProjectInfoMethod · 0.45
setWorkingDirectoryMethod · 0.45
readMethod · 0.45
appendMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected