Commit 671a0456 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Add files before commiting in case they're not staged yet.

Makes it possible to add files from the Patch Review UI.
parent bb6a360a
......@@ -341,13 +341,38 @@ VcsJob* GitPlugin::commit(const QString& message,
if (localLocations.empty() || message.isEmpty())
return errorsFound(i18n("No files or message specified"));
DVcsJob* job = new DVcsJob(dotGitDirectory(localLocations.front()), this);
QDir dir = dotGitDirectory(localLocations.front());
DVcsJob* job = new DVcsJob(dir, this);
KUrl::List files = (recursion == IBasicVersionControl::Recursive ? localLocations : preventRecursion(localLocations));
addNotVersionedFiles(dir, files);
*job << "git" << "commit" << "-m" << message;
*job << "--" << (recursion == IBasicVersionControl::Recursive ? localLocations : preventRecursion(localLocations));
*job << "--" << files;
return job;
}
void GitPlugin::addNotVersionedFiles(const QDir& dir, const KUrl::List& files)
{
QStringList otherStr = getLsFiles(dir, QStringList() << "--others", KDevelop::OutputJob::Silent);
KUrl::List toadd, otherFiles;
foreach(const QString& file, otherStr) {
KUrl v(dir.absolutePath());
v.addPath(file);
otherFiles += v;
}
//We add the files that are not versioned
foreach(const KUrl& file, files) {
if(otherFiles.contains(file) && QFileInfo(file.toLocalFile()).isFile())
toadd += file;
}
VcsJob* job = add(toadd);
job->exec();
}
VcsJob* GitPlugin::remove(const KUrl::List& files)
{
if (files.isEmpty())
......@@ -1026,10 +1051,8 @@ VcsJob* GitPlugin::copy(const KUrl& localLocationSrc, const KUrl& localLocationD
VcsJob* GitPlugin::move(const KUrl& source, const KUrl& destination)
{
DVcsJob* job = new DVcsJob(urlDir(source), this, KDevelop::OutputJob::Verbose);
{
*job << "git" << "mv" << source.toLocalFile() << destination.toLocalFile();
return job;
}
*job << "git" << "mv" << source.toLocalFile() << destination.toLocalFile();
return job;
}
void GitPlugin::parseGitRepoLocationOutput(DVcsJob* job)
......
......@@ -167,6 +167,8 @@ private slots:
void ctxStashManager();
private:
void addNotVersionedFiles(const QDir& dir, const KUrl::List& files);
//commit dialog "main" helper
QStringList getLsFiles(const QDir &directory, const QStringList &args,
KDevelop::OutputJob::OutputJobVerbosity verbosity);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment