Changeset View
Changeset View
Standalone View
Standalone View
plugins/git/gitplugin.cpp
Show First 20 Lines • Show All 274 Lines • ▼ Show 20 Line(s) | |||||
275 | 275 | | |||
276 | bool GitPlugin::isValidDirectory(const QUrl & dirPath) | 276 | bool GitPlugin::isValidDirectory(const QUrl & dirPath) | ||
277 | { | 277 | { | ||
278 | QDir dir=dotGitDirectory(dirPath); | 278 | QDir dir=dotGitDirectory(dirPath); | ||
279 | 279 | | |||
280 | return dir.exists(QStringLiteral(".git/HEAD")); | 280 | return dir.exists(QStringLiteral(".git/HEAD")); | ||
281 | } | 281 | } | ||
282 | 282 | | |||
283 | bool GitPlugin::isValidRemoteRepositoryUrl(const QUrl& remoteLocation) | ||||
284 | { | ||||
285 | if (remoteLocation.isLocalFile()) { | ||||
286 | QFileInfo fileInfo(remoteLocation.toLocalFile()); | ||||
287 | if (fileInfo.isDir()) { | ||||
288 | QDir dir(fileInfo.filePath()); | ||||
289 | if (dir.exists(QStringLiteral(".git/HEAD"))) { | ||||
290 | return true; | ||||
291 | } | ||||
292 | // TODO: check also for bare repo | ||||
293 | } | ||||
294 | } else { | ||||
295 | const QString scheme = remoteLocation.scheme(); | ||||
296 | if (scheme == QLatin1String("git")) { | ||||
297 | return true; | ||||
298 | } | ||||
299 | // heuristic check, anything better we can do here without talking to server? | ||||
300 | if ((scheme == QLatin1String("http") || | ||||
301 | scheme == QLatin1String("https")) && | ||||
302 | remoteLocation.path().endsWith(QLatin1String(".git"))) { | ||||
303 | return true; | ||||
304 | } | ||||
305 | } | ||||
306 | return false; | ||||
307 | } | ||||
308 | | ||||
283 | bool GitPlugin::isVersionControlled(const QUrl &path) | 309 | bool GitPlugin::isVersionControlled(const QUrl &path) | ||
284 | { | 310 | { | ||
285 | QFileInfo fsObject(path.toLocalFile()); | 311 | QFileInfo fsObject(path.toLocalFile()); | ||
286 | if (!fsObject.exists()) { | 312 | if (!fsObject.exists()) { | ||
287 | return false; | 313 | return false; | ||
288 | } | 314 | } | ||
289 | if (fsObject.isDir()) { | 315 | if (fsObject.isDir()) { | ||
290 | return isValidDirectory(path); | 316 | return isValidDirectory(path); | ||
▲ Show 20 Lines • Show All 1220 Lines • Show Last 20 Lines |