! Setup distributed version control for a new project defined by @p info. Use @p scratchArea for temporary files */
| 140 | |
| 141 | /*! Setup distributed version control for a new project defined by @p info. Use @p scratchArea for temporary files */ |
| 142 | bool 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 */ |
| 190 | bool initializeCVCS(ICentralizedVersionControl* cvcs, const ApplicationInfo& info, QTemporaryDir& scratchArea) |
no test coverage detected