Commit a0c7b208 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Git: Factor source directory resolving to a function



Change-Id: Ica2f6ad01052fb7130397740fcf2396de7cbbf9d
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 9b11b0ef
......@@ -206,15 +206,13 @@ void GitEditor::commandFinishedGotoLine(bool ok, int exitCode, const QVariant &v
void GitEditor::checkoutChange()
{
const QFileInfo fi(source());
const QString workingDirectory = fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath();
GitPlugin::instance()->gitClient()->stashAndCheckout(workingDirectory, m_currentChange);
GitPlugin::instance()->gitClient()->stashAndCheckout(
sourceWorkingDirectory(), m_currentChange);
}
void GitEditor::resetChange()
{
const QFileInfo fi(source());
const QString workingDir = fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath();
const QString workingDir = sourceWorkingDirectory();
GitClient *client = GitPlugin::instance()->gitClient();
if (client->gitStatus(workingDir, StatusMode(NoUntracked | NoSubmodules))
......@@ -232,16 +230,14 @@ void GitEditor::resetChange()
void GitEditor::cherryPickChange()
{
const QFileInfo fi(source());
const QString workingDirectory = fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath();
GitPlugin::instance()->gitClient()->synchronousCherryPick(workingDirectory, m_currentChange);
GitPlugin::instance()->gitClient()->synchronousCherryPick(
sourceWorkingDirectory(), m_currentChange);
}
void GitEditor::revertChange()
{
const QFileInfo fi(source());
const QString workingDirectory = fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath();
GitPlugin::instance()->gitClient()->synchronousRevert(workingDirectory, m_currentChange);
GitPlugin::instance()->gitClient()->synchronousRevert(
sourceWorkingDirectory(), m_currentChange);
}
void GitEditor::stageDiffChunk()
......@@ -402,5 +398,11 @@ QString GitEditor::fileNameForLine(int line) const
return source();
}
QString GitEditor::sourceWorkingDirectory() const
{
const QFileInfo fi(source());
return fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath();
}
} // namespace Internal
} // namespace Git
......@@ -77,6 +77,7 @@ private:
QString revisionSubject(const QTextBlock &inBlock) const;
bool supportChangeLinks() const;
QString fileNameForLine(int line) const;
QString sourceWorkingDirectory() const;
mutable QRegExp m_changeNumberPattern;
QString m_currentChange;
......
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