logic: fixed custom commands

* allow filesystem to rename temp db after indexing
* changed custom command variable syntax
* adjusted test checklist for custom commands
This commit is contained in:
mlangkabel
2018-12-18 15:02:45 +01:00
parent e3940fdf19
commit b4ea675c9a
4 changed files with 18 additions and 17 deletions
@@ -85,6 +85,7 @@ Task::TaskState TaskExecuteCustomCommands::doUpdate(std::shared_ptr<Blackboard>
void TaskExecuteCustomCommands::doExit(std::shared_ptr<Blackboard> blackboard)
{
m_storage.reset();
float duration = utility::duration(m_start);
blackboard->update<float>("index_time", [duration](float currentDuration) { return currentDuration + duration; });
}
+4 -4
View File
@@ -42,16 +42,16 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCustomCommand::getIndexe
{
std::wstring customCommand = m_settings->getCustomCommand();
customCommand = utility::replace(customCommand, L"$PROJECT_PATH", L'\"' + m_settings->getProjectSettings()->getProjectFilePath().wstr() + L'\"');
customCommand = utility::replace(customCommand, L"$DB_PATH", L'\"' + m_settings->getProjectSettings()->getTempDBFilePath().wstr() + L'\"');
customCommand = utility::replace(customCommand, L"$DB_VERSION", L'\"' + std::to_wstring(SqliteIndexStorage::getStorageVersion()) + L'\"');
customCommand = utility::replace(customCommand, L"%{PROJECT_FILE_PATH}", L'\"' + m_settings->getProjectSettings()->getProjectFilePath().wstr() + L'\"');
customCommand = utility::replace(customCommand, L"%{DATABASE_FILE_PATH}", L'\"' + m_settings->getProjectSettings()->getTempDBFilePath().wstr() + L'\"');
customCommand = utility::replace(customCommand, L"%{DATABASE_VERSION}", L'\"' + std::to_wstring(SqliteIndexStorage::getStorageVersion()) + L'\"');
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
for (const FilePath& sourcePath: getAllSourceFilePaths())
{
if (filesToIndex.find(sourcePath) != filesToIndex.end())
{
std::wstring command = utility::replace(customCommand, L"$SOURCE_PATH", L'\"' + sourcePath.wstr() + L'\"');
std::wstring command = utility::replace(customCommand, L"%{SOURCE_FILE_PATH}", L'\"' + sourcePath.wstr() + L'\"');
indexerCommands.push_back(std::make_shared<IndexerCommandCustom>(sourcePath, command));
}
@@ -31,15 +31,15 @@ void QtProjectWizzardContentCustomCommand::populate(QGridLayout* layout, int& ro
addHelpButton(
"Custom Command",
"<p>Specify the commandline call that will be executed for each source file in this Source Group. "
"You can use the following variables, $SOURCE_PATH is mandatory.</p>"
"You can use the following variables, %{SOURCE_FILE_PATH} is mandatory.</p>"
"<ul>"
"<li><b>$SOURCE_PATH</b> - Path to each source file (mandatory)</li>"
"<li><b>$PROJECT_PATH</b> - Path to project file: \"" +
QString::fromStdWString(m_settings->getProjectSettings()->getProjectFilePath().wstr()) + "\"</li>"
"<li><b>$DB_PATH</b> - Path to database file: \"" +
"<li><b>%{SOURCE_FILE_PATH}</b> - Path to each source file (mandatory)</li>"
"<li><b>%{DATABASE_FILE_PATH}</b> - Path to database file: \"" +
QString::fromStdWString(m_settings->getProjectSettings()->getTempDBFilePath().wstr()) + "\"</li>"
"<li><b>$DB_VERSION</b> - Database version used by this Sourcetrail version: \"" +
"<li><b>%{DATABASE_VERSION}</b> - Database version used by this Sourcetrail version: \"" +
QString::number(SqliteIndexStorage::getStorageVersion()) + "\"</li>"
"<li><b>%{PROJECT_FILE_PATH}</b> - Path to project file: \"" +
QString::fromStdWString(m_settings->getProjectSettings()->getProjectFilePath().wstr()) + "\"</li>"
"</ul>",
layout, row
);
@@ -80,10 +80,10 @@ bool QtProjectWizzardContentCustomCommand::check()
return false;
}
if (m_customCommand->text().toStdWString().find(L"$SOURCE_PATH") == std::wstring::npos)
if (m_customCommand->text().toStdWString().find(L"%{SOURCE_FILE_PATH}") == std::wstring::npos)
{
QMessageBox msgBox;
msgBox.setText("The variable $SOURCE_PATH is missing in the custom command.");
msgBox.setText("The variable %{SOURCE_FILE_PATH} is missing in the custom command.");
msgBox.exec();
return false;
}
@@ -6,8 +6,7 @@
* Click "Add Source Group"
* Select "Custom" -> "Custom Command Source Group"
* Click "Next"
* Click "Next"
* Add "python add.py $PROJECT_PATH $DB_PATH $DB_VERSION $SOURCE_PATH" to "Custom Command"
* Add "python add.py %{PROJECT_FILE_PATH} %{DATABASE_FILE_PATH} %{DATABASE_VERSION} %{SOURCE_FILE_PATH}" to "Custom Command"
* Add "./src" to "Files & Directories to Index"
* Add "**excl.txt" to "Excluded Files & Directories"
* Add ".txt" to "Source File Extensions"
@@ -28,9 +27,10 @@
* Click "Cancel"
* Click "Edit Project"
* Change "Custom Command" to "pyt add.py"
* Click "Next"
* Validate "Warning appears that $SOURCE_PATH is not defined in command"
* Change "Custom Command" to "pyt add.py $SOURCE_PATH"
* Click "Save"
* Validate "Warning appears that %{SOURCE_FILE_PATH} is not defined in command"
* Change "Custom Command" to "pyt add.py %{SOURCE_FILE_PATH}"
* Click "Save"
* Click "Refresh" button
* Click "Start"
* Validate "Log View appears showing errors that command execution failed".