Fix missing build date in package search

* Avoid using buildDate of PackageInfo in favor of the same field in
  PackageBase
    * PackageInfo::buildDate should be removed on the next breaking change
* Do not really use the deprecated attribute because it is still used by
  (de)serialization code until it is removed for good
This commit is contained in:
Martchus 2022-06-08 22:44:58 +02:00
parent 94c4b8addc
commit c155176098
7 changed files with 13 additions and 13 deletions

View File

@ -100,8 +100,8 @@ static void printPackageSearchResults(const LibRepoMgr::WebClient::Response::bod
t.add_row({ "Arch", "Repo", "Name", "Version", "Description", "Build date" });
for (const auto &[db, package, packageID] : packages) {
const auto &dbInfo = std::get<LibPkg::DatabaseInfo>(db);
t.add_row({ package->packageInfo ? package->arch : dbInfo.arch, dbInfo.name, package->name, package->version, package->description,
package->packageInfo && !package->buildDate.isNull() ? package->packageInfo->buildDate.toString() : "?" });
t.add_row({ !package->arch.empty() ? package->arch : dbInfo.arch, dbInfo.name, package->name, package->version, package->description,
!package->buildDate.isNull() ? package->buildDate.toString() : "?" });
}
t.row(0).format().font_align(tabulate::FontAlign::center).font_style({ tabulate::FontStyle::bold });
configureColumnWidths(t);
@ -154,9 +154,9 @@ static void printPackageDetails(const LibRepoMgr::WebClient::Response::body_type
if (!pkg->packageInfo->packager.empty()) {
t.add_row({ "Packager", pkg->packageInfo->packager });
}
if (!pkg->packageInfo->buildDate.isNull()) {
t.add_row({ "Packager", pkg->packageInfo->buildDate.toString() });
}
}
if (!pkg->buildDate.isNull()) {
t.add_row({ "Build date", pkg->buildDate.toString() });
}
t.add_row({ "Dependencies", formatDependencies(pkg->dependencies) });
t.add_row({ "Optional dependencies", formatDependencies(pkg->optionalDependencies) });

View File

@ -377,8 +377,7 @@ bool Package::addDepsAndProvidesFromOtherPackage(const Package &otherPackage, bo
if (!force
&& ((otherPackage.origin != PackageOrigin::PackageContents && otherPackage.origin != PackageOrigin::CustomSource)
|| version != otherPackage.version
|| !(!packageInfo || packageInfo->buildDate.isNull()
|| (otherPackage.packageInfo && packageInfo->buildDate == otherPackage.packageInfo->buildDate)))) {
|| !(!packageInfo || buildDate.isNull() || (otherPackage.packageInfo && buildDate == otherPackage.buildDate)))) {
return false;
}

View File

@ -228,7 +228,7 @@ struct LIBPKG_EXPORT PackageInfo : public ReflectiveRapidJSON::JsonSerializable<
public ReflectiveRapidJSON::BinarySerializable<PackageInfo> {
std::string fileName;
std::vector<std::string> files;
CppUtilities::DateTime buildDate;
/* [[deprecated("redundant with field in PackageBase; remove at some point")]] */ CppUtilities::DateTime buildDate;
std::string packager;
std::string md5;
std::string sha256;

View File

@ -285,8 +285,9 @@ static void addPackageInfo(Package &package, PackageVersion &version, const char
}
else_if_field("builddate")
{
package.buildDate = DateTime::fromTimeStampGmt(stringToNumber<std::time_t>(valueString));
ensure_pkg_info;
package.packageInfo->buildDate = DateTime::fromTimeStampGmt(stringToNumber<std::time_t>(valueString));
package.packageInfo->buildDate = package.buildDate;
}
else_if_field("packager")
{
@ -355,7 +356,7 @@ static void addPackageDescription(Package &package, const char *field, size_t fi
}
else_if_field("BUILDDATE")
{
package.packageInfo->buildDate = DateTime::fromTimeStampGmt(stringToNumber<time_t>(valueString));
package.buildDate = package.packageInfo->buildDate = DateTime::fromTimeStampGmt(stringToNumber<time_t>(valueString));
}
else_if_field("INSTALLDATE")
{

View File

@ -83,7 +83,7 @@ void checkAutoconfPackage(const Package &pkg)
CPPUNIT_ASSERT_EQUAL_MESSAGE("packer"s, "Allan McRae <allan@archlinux.org>"s, pkg.packageInfo->packager);
CPPUNIT_ASSERT_EQUAL_MESSAGE("package arch"s, "any"s, pkg.arch);
CPPUNIT_ASSERT_EQUAL_MESSAGE("package file name"s, "autoconf-2.69-4-any.pkg.tar.xz"s, pkg.packageInfo->fileName);
CPPUNIT_ASSERT_EQUAL_MESSAGE("package build date"s, 636089958990000000ul, pkg.packageInfo->buildDate.totalTicks());
CPPUNIT_ASSERT_EQUAL_MESSAGE("package build date"s, 636089958990000000ul, pkg.buildDate.totalTicks());
CPPUNIT_ASSERT_EQUAL_MESSAGE("package files"s, 74ul, pkg.packageInfo->files.size());
CPPUNIT_ASSERT_EQUAL("usr/"s, pkg.packageInfo->files.front());
const vector<Dependency> makeDependencies = { Dependency("help2man"s) };

View File

@ -229,7 +229,7 @@ bool ReloadLibraryDependencies::addRelevantPackage(LibPkg::StorageID packageID,
// -> assign certain fields which are used by addDepsAndProvidesFromOtherPackage() to check whether the packages are matching
relevantPkg.info.version = package->version;
relevantPkg.info.packageInfo = std::make_optional<LibPkg::PackageInfo>();
relevantPkg.info.packageInfo->buildDate = package->packageInfo->buildDate;
relevantPkg.info.buildDate = package->buildDate;
// -> gather source info such as make and check dependencies as well
relevantPkg.info.sourceInfo = std::make_optional<LibPkg::SourceInfo>();
++m_remainingPackages;

View File

@ -69,7 +69,7 @@ export function renderDependency(mode, value)
}
const labelsWithoutBasics = ['Architecture', 'Repository', 'Description', 'Upstream URL', 'License(s)', 'Groups', 'Package size', 'Installed size', 'Packager', 'Build date', 'Dependencies', 'Optional dependencies', 'Make dependencies', 'Check dependencies', 'Provides', 'Replaces', 'Conflicts', 'Contained libraries', 'Needed libraries', 'Files'];
const fieldsWithoutBasics = ['arch', 'db', 'description', 'upstreamUrl', 'licenses', 'groups', 'packageInfo.size', 'installInfo.installedSize', 'packageInfo.packager', 'packageInfo.buildDate', 'dependencies', 'optionalDependencies', 'sourceInfo.makeDependencies', 'sourceInfo.checkDependencies', 'provides', 'replaces', 'conflicts', 'libprovides', 'libdepends', 'packageInfo.files'];
const fieldsWithoutBasics = ['arch', 'db', 'description', 'upstreamUrl', 'licenses', 'groups', 'packageInfo.size', 'installInfo.installedSize', 'packageInfo.packager', 'buildDate', 'dependencies', 'optionalDependencies', 'sourceInfo.makeDependencies', 'sourceInfo.checkDependencies', 'provides', 'replaces', 'conflicts', 'libprovides', 'libdepends', 'packageInfo.files'];
const labelsWithBasics = ['Name', 'Version', ...labelsWithoutBasics];
const fieldsWithBasics = ['name', 'version', ...fieldsWithoutBasics];