MCPcopy Create free account
hub / github.com/KDE/kdevelop / initializeDVCS

Function initializeDVCS

plugins/appwizard/appwizardplugin.cpp:142–187  ·  view source on GitHub ↗

! Setup distributed version control for a new project defined by @p info. Use @p scratchArea for temporary files */

Source from the content-addressed store, hash-verified

140
141/*! Setup distributed version control for a new project defined by @p info. Use @p scratchArea for temporary files */
142bool initializeDVCS(IDistributedVersionControl* dvcs, const ApplicationInfo& info, QTemporaryDir& scratchArea)
143{
144 Q_ASSERT(dvcs);
145 qCDebug(PLUGIN_APPWIZARD) << "DVCS system is used, just initializing DVCS";
146
147 const QUrl& dest = info.location;
148 //TODO: check if we want to handle KDevelop project files (like now) or only SRC dir
149 VcsJob* job = dvcs->init(dest);
150 if (!job || !job->exec() || job->status() != VcsJob::JobSucceeded)
151 {
152 vcsError(i18n("Could not initialize DVCS repository"), scratchArea, dest);
153 return false;
154 }
155 qCDebug(PLUGIN_APPWIZARD) << "Initializing DVCS repository:" << dest;
156
157 qCDebug(PLUGIN_APPWIZARD) << "Checking for valid files in the DVCS repository:" << dest;
158 job = dvcs->status({dest}, KDevelop::IBasicVersionControl::Recursive);
159 if (!job || !job->exec() || job->status() != VcsJob::JobSucceeded)
160 {
161 vcsError(i18n("Could not check status of the DVCS repository"), scratchArea, dest);
162 return false;
163 }
164
165 if (job->fetchResults().toList().isEmpty())
166 {
167 qCDebug(PLUGIN_APPWIZARD) << "No files to add, skipping commit in the DVCS repository:" << dest;
168 return true;
169 }
170
171 job = dvcs->add({dest}, KDevelop::IBasicVersionControl::Recursive);
172 if (!job || !job->exec() || job->status() != VcsJob::JobSucceeded)
173 {
174 vcsError(i18n("Could not add files to the DVCS repository"), scratchArea, dest);
175 return false;
176 }
177
178 job = dvcs->commit(info.importCommitMessage, {dest},
179 KDevelop::IBasicVersionControl::Recursive);
180 if (!job || !job->exec() || job->status() != VcsJob::JobSucceeded)
181 {
182 vcsError(i18n("Could not import project into %1.", dvcs->name()), scratchArea, dest, job ? job->errorString() : QString());
183 return false;
184 }
185
186 return true; // We're good
187}
188
189/*! Setup version control for a new project defined by @p info. Use @p scratchArea for temporary files */
190bool initializeCVCS(ICentralizedVersionControl* cvcs, const ApplicationInfo& info, QTemporaryDir& scratchArea)

Callers 1

createProjectMethod · 0.85

Calls 12

vcsErrorFunction · 0.85
execMethod · 0.80
QStringClass · 0.50
initMethod · 0.45
statusMethod · 0.45
isEmptyMethod · 0.45
toListMethod · 0.45
fetchResultsMethod · 0.45
addMethod · 0.45
commitMethod · 0.45
nameMethod · 0.45
errorStringMethod · 0.45

Tested by

no test coverage detected