From b4ea675c9ae8bdd1f80f92ff91592b1fe971b778 Mon Sep 17 00:00:00 2001
From: mlangkabel
Date: Tue, 18 Dec 2018 15:02:45 +0100
Subject: [PATCH] logic: fixed custom commands
* allow filesystem to rename temp db after indexing
* changed custom command variable syntax
* adjusted test checklist for custom commands
---
.../data/indexer/TaskExecuteCustomCommands.cpp | 1 +
src/lib/project/SourceGroupCustomCommand.cpp | 8 ++++----
.../QtProjectWizzardContentCustomCommand.cpp | 16 ++++++++--------
.../project_setup/custom_command/checklist.txt | 10 +++++-----
4 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/src/lib/data/indexer/TaskExecuteCustomCommands.cpp b/src/lib/data/indexer/TaskExecuteCustomCommands.cpp
index dbb614bd..9c54a784 100644
--- a/src/lib/data/indexer/TaskExecuteCustomCommands.cpp
+++ b/src/lib/data/indexer/TaskExecuteCustomCommands.cpp
@@ -85,6 +85,7 @@ Task::TaskState TaskExecuteCustomCommands::doUpdate(std::shared_ptr
void TaskExecuteCustomCommands::doExit(std::shared_ptr blackboard)
{
+ m_storage.reset();
float duration = utility::duration(m_start);
blackboard->update("index_time", [duration](float currentDuration) { return currentDuration + duration; });
}
diff --git a/src/lib/project/SourceGroupCustomCommand.cpp b/src/lib/project/SourceGroupCustomCommand.cpp
index fa5bcc3e..aea48180 100644
--- a/src/lib/project/SourceGroupCustomCommand.cpp
+++ b/src/lib/project/SourceGroupCustomCommand.cpp
@@ -42,16 +42,16 @@ std::vector> 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> 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(sourcePath, command));
}
diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCustomCommand.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCustomCommand.cpp
index 6f2b1d1d..db45f750 100644
--- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCustomCommand.cpp
+++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCustomCommand.cpp
@@ -31,15 +31,15 @@ void QtProjectWizzardContentCustomCommand::populate(QGridLayout* layout, int& ro
addHelpButton(
"Custom Command",
"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.
"
+ "You can use the following variables, %{SOURCE_FILE_PATH} is mandatory.
"
""
- "- $SOURCE_PATH - Path to each source file (mandatory)
"
- "- $PROJECT_PATH - Path to project file: \"" +
- QString::fromStdWString(m_settings->getProjectSettings()->getProjectFilePath().wstr()) + "\"
"
- "- $DB_PATH - Path to database file: \"" +
+ "
- %{SOURCE_FILE_PATH} - Path to each source file (mandatory)
"
+ "- %{DATABASE_FILE_PATH} - Path to database file: \"" +
QString::fromStdWString(m_settings->getProjectSettings()->getTempDBFilePath().wstr()) + "\"
"
- "- $DB_VERSION - Database version used by this Sourcetrail version: \"" +
+ "
- %{DATABASE_VERSION} - Database version used by this Sourcetrail version: \"" +
QString::number(SqliteIndexStorage::getStorageVersion()) + "\"
"
+ "- %{PROJECT_FILE_PATH} - Path to project file: \"" +
+ QString::fromStdWString(m_settings->getProjectSettings()->getProjectFilePath().wstr()) + "\"
"
"
",
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;
}
diff --git a/testing/project_setup/custom_command/checklist.txt b/testing/project_setup/custom_command/checklist.txt
index a265ec8a..bb47f4d2 100644
--- a/testing/project_setup/custom_command/checklist.txt
+++ b/testing/project_setup/custom_command/checklist.txt
@@ -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".