Newer
Older
// Note: This menu is visible if there is no repository. Only
// 'Create Repository'/'Show' actions should be available.
const QString fileName = currentState().currentFileName();
foreach (Utils::ParameterAction *fileAction, m_fileActions)
fileAction->setParameter(fileName);
// If the current file looks like a patch, offer to apply
m_applyCurrentFilePatchAction->setParameter(currentState().currentPatchFileDisplayName());
const QString projectName = currentState().currentProjectName();
foreach (Utils::ParameterAction *projectAction, m_projectActions)
projectAction->setParameter(projectName);
foreach (QAction *repositoryAction, m_repositoryActions)
repositoryAction->setEnabled(repositoryEnabled);
updateRepositoryBrowserAction();
// Prompts for repo.
m_showAction->setEnabled(true);
void GitPlugin::updateRepositoryBrowserAction()
{
const bool repositoryEnabled = currentState().hasTopLevel();
const bool hasRepositoryBrowserCmd = !settings().stringValue(GitSettings::repositoryBrowserCmd).isEmpty();
m_repositoryBrowserAction->setEnabled(repositoryEnabled && hasRepositoryBrowserCmd);
}
if (!m_changeSelectionDialog)
m_changeSelectionDialog = new ChangeSelectionDialog();
if (state.hasFile())
m_changeSelectionDialog->setWorkingDirectory(state.currentFileDirectory());
else if (state.hasTopLevel())
m_changeSelectionDialog->setWorkingDirectory(state.topLevel());
if (m_changeSelectionDialog->exec() != QDialog::Accepted)
return;
const QString change = m_changeSelectionDialog->change();
if (change.isEmpty())
m_gitClient->show(m_changeSelectionDialog->workingDirectory(), change);
const GitSettings &GitPlugin::settings() const
}
void GitPlugin::setSettings(const GitSettings &s)
{
if (s == m_settings)
return;
m_settings = s;
static_cast<GitVersionControl *>(versionControl())->emitConfigurationChanged();
updateRepositoryBrowserAction();
}
GitClient *GitPlugin::gitClient() const
{
return m_gitClient;
}
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
#ifdef WITH_TESTS
#include <QTest>
Q_DECLARE_METATYPE(CommitData::FileState)
void GitPlugin::testStatusParsing_data()
{
QTest::addColumn<QString>("line");
QTest::addColumn<CommitData::FileState>("first");
QTest::addColumn<CommitData::FileState>("second");
#define STATUS_TEST(status, first, second) \
QTest::newRow(status) << QString::fromLatin1(status) << CommitData::first << CommitData::second;
STATUS_TEST(" M", ModifiedFile, UnknownFileState);
STATUS_TEST(" D", DeletedFile, UnknownFileState);
STATUS_TEST("M ", ModifiedStagedFile, UnknownFileState);
STATUS_TEST("MM", ModifiedStagedFile, ModifiedFile);
STATUS_TEST("MD", ModifiedStagedFile, DeletedFile);
STATUS_TEST("A ", AddedStagedFile, UnknownFileState);
STATUS_TEST("AM", AddedStagedFile, ModifiedFile);
STATUS_TEST("AD", AddedStagedFile, DeletedFile);
STATUS_TEST("D ", DeletedStagedFile, UnknownFileState);
STATUS_TEST("DM", DeletedStagedFile, ModifiedFile);
STATUS_TEST("R ", RenamedStagedFile, UnknownFileState);
STATUS_TEST("RM", RenamedStagedFile, ModifiedFile);
STATUS_TEST("RD", RenamedStagedFile, DeletedFile);
STATUS_TEST("C ", CopiedStagedFile, UnknownFileState);
STATUS_TEST("CM", CopiedStagedFile, ModifiedFile);
STATUS_TEST("CD", CopiedStagedFile, DeletedFile);
}
void GitPlugin::testStatusParsing()
{
CommitData data;
QFETCH(QString, line);
QFETCH(CommitData::FileState, first);
QFETCH(CommitData::FileState, second);
QString output = QLatin1String("## master...origin/master [ahead 1]\n");
output += line + QLatin1String(" main.cpp\n");
data.parseFilesFromStatus(output);
QCOMPARE(data.files.at(0).first, first);
if (second != CommitData::UnknownFileState)
QCOMPARE(data.files.at(1).first, second);
}
#endif