forked from qt-creator/qt-creator
UpdateInfo: Fix parsing of update info
It was no longer showing any updates. At some point MaintenanceTool added <?xml...> headers to its responses, which broke our combine-and- parse hack, since such a header in the middle of XML is invalid. Add a hack that removes these headers first. This should be refactored without the use of ShellCommand in master, because that doesn't allow us to access the output of the two jobs separately. Change-Id: I7248b070a8edb1a45248b3531ed50bb0d94eef73 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QVersionNumber>
|
#include <QVersionNumber>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -40,8 +41,11 @@ Q_DECLARE_LOGGING_CATEGORY(log)
|
|||||||
std::unique_ptr<QDomDocument> documentForResponse(const QString &response)
|
std::unique_ptr<QDomDocument> documentForResponse(const QString &response)
|
||||||
{
|
{
|
||||||
// since the output can contain two toplevel items from the two separate MaintenanceTool runs,
|
// since the output can contain two toplevel items from the two separate MaintenanceTool runs,
|
||||||
// surround with a toplevel element
|
// clean up any <?xml version="1.0"?> and surround with a toplevel element
|
||||||
const QString xml = response.isEmpty() ? QString() : ("<doc>" + response + "</doc>");
|
QString responseWithoutHeader = response;
|
||||||
|
responseWithoutHeader.remove(QRegularExpression("<\\?xml.*\\?>"));
|
||||||
|
const QString xml = response.isEmpty() ? QString()
|
||||||
|
: ("<doc>" + responseWithoutHeader + "</doc>");
|
||||||
std::unique_ptr<QDomDocument> doc(new QDomDocument);
|
std::unique_ptr<QDomDocument> doc(new QDomDocument);
|
||||||
doc->setContent(xml);
|
doc->setContent(xml);
|
||||||
return doc;
|
return doc;
|
||||||
|
@@ -45,9 +45,11 @@ void tst_UpdateInfo::updates_data()
|
|||||||
QTest::addColumn<QList<QtPackage>>("xpackages");
|
QTest::addColumn<QList<QtPackage>>("xpackages");
|
||||||
|
|
||||||
QTest::newRow("updates and packages")
|
QTest::newRow("updates and packages")
|
||||||
<< R"raw(<updates>
|
<< R"raw(<?xml version="1.0"?>
|
||||||
|
<updates>
|
||||||
<update name="Qt Design Studio 3.2.0" version="3.2.0-0-202203291247" size="3113234690" id="qt.tools.qtdesignstudio"/>
|
<update name="Qt Design Studio 3.2.0" version="3.2.0-0-202203291247" size="3113234690" id="qt.tools.qtdesignstudio"/>
|
||||||
</updates>
|
</updates>
|
||||||
|
<?xml version="1.0"?>
|
||||||
<availablepackages>
|
<availablepackages>
|
||||||
<package name="qt.qt6.621" displayname="Qt 6.2.1" version="6.2.1-0-202110220854"/>
|
<package name="qt.qt6.621" displayname="Qt 6.2.1" version="6.2.1-0-202110220854"/>
|
||||||
<package name="qt.qt5.5152" displayname="Qt 5.15.2" version="5.15.2-0-202011130607" installedVersion="5.15.2-0-202011130607"/>
|
<package name="qt.qt5.5152" displayname="Qt 5.15.2" version="5.15.2-0-202011130607" installedVersion="5.15.2-0-202011130607"/>
|
||||||
|
Reference in New Issue
Block a user