aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-20 17:20:08 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-20 17:20:08 +0000
commit8c3decbad616902b8ffbf7d3a8cda8cbf8cbf8f8 (patch)
tree076b7aa2b379334a94c9fb4ca702300aaf48b929
parent03258d6753061be2a6611764b50c96ed0eee6198 (diff)
downloadpaludis-8c3decbad616902b8ffbf7d3a8cda8cbf8cbf8f8.tar.gz
paludis-8c3decbad616902b8ffbf7d3a8cda8cbf8cbf8f8.tar.xz
Re-add changelog check.
-rw-r--r--paludis/repositories/e/qa/Makefile.am2
-rw-r--r--paludis/repositories/e/qa/changelog.cc73
-rw-r--r--paludis/repositories/e/qa/changelog.hh38
-rw-r--r--paludis/repositories/e/qa/misc_files.cc3
-rw-r--r--paludis/repositories/e/qa/misc_files_TEST.cc19
-rwxr-xr-xpaludis/repositories/e/qa/misc_files_TEST_setup.sh9
-rw-r--r--paludis/repositories/e/qa/qa_checks.cc4
7 files changed, 119 insertions, 29 deletions
diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am
index 7505c0e..4b0a190 100644
--- a/paludis/repositories/e/qa/Makefile.am
+++ b/paludis/repositories/e/qa/Makefile.am
@@ -48,6 +48,7 @@ paludis_repositories_e_include_HEADERS = \
variable_assigns.hh \
gpg.hh \
ebuild_count.hh \
+ changelog.hh \
misc_files.hh \
files_dir_size.hh \
repo_name.hh \
@@ -77,6 +78,7 @@ libpaludiserepositoryqa_la_SOURCES = \
variable_assigns.cc \
gpg.cc \
ebuild_count.cc \
+ changelog.cc \
misc_files.cc \
files_dir_size.cc \
repo_name.cc \
diff --git a/paludis/repositories/e/qa/changelog.cc b/paludis/repositories/e/qa/changelog.cc
new file mode 100644
index 0000000..77f3272
--- /dev/null
+++ b/paludis/repositories/e/qa/changelog.cc
@@ -0,0 +1,73 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "changelog.hh"
+#include <paludis/qa.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/log.hh>
+#include <fstream>
+
+using namespace paludis;
+
+bool
+paludis::erepository::changelog_check(
+ QAReporter & reporter,
+ const FSEntry & dir,
+ const QualifiedPackageName & qpn,
+ const std::string & name
+ )
+{
+ Context context("When performing check '" + name + "' using changelog_check on directory '" + stringify(dir) + "':");
+ Log::get_instance()->message(ll_debug, lc_context) << "changelog_check '"
+ << dir << "', " << name << "'";
+
+ FSEntry f(dir / "ChangeLog");
+
+ if (! f.exists())
+ reporter.message(QAMessage(f, qaml_normal, name, "No ChangeLog found"));
+ else if (! f.is_regular_file_or_symlink_to_regular_file())
+ reporter.message(QAMessage(f, qaml_normal, name, "Not a regular file"));
+ else
+ {
+ std::ifstream ff(stringify(f).c_str());
+ do
+ {
+ if (! ff)
+ {
+ reporter.message(QAMessage(f, qaml_normal, name, "Can't read ChangeLog"));
+ continue;
+ }
+
+ std::string s;
+ if (! std::getline(ff, s))
+ {
+ reporter.message(QAMessage(f, qaml_normal, name, "Can't read ChangeLog header"));
+ continue;
+ }
+
+ if (s != "# ChangeLog for " + stringify(qpn))
+ reporter.message(QAMessage(f, qaml_minor, name, "ChangeLog header is incorrect"));
+ }
+ while (false);
+ }
+
+ return true;
+}
+
diff --git a/paludis/repositories/e/qa/changelog.hh b/paludis/repositories/e/qa/changelog.hh
new file mode 100644
index 0000000..bc7ba8f
--- /dev/null
+++ b/paludis/repositories/e/qa/changelog.hh
@@ -0,0 +1,38 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_CHANGELOG_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_CHANGELOG_HH 1
+
+#include <paludis/repositories/e/qa/qa_controller.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ bool changelog_check(
+ QAReporter &,
+ const FSEntry &,
+ const QualifiedPackageName &,
+ const std::string &
+ );
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/qa/misc_files.cc b/paludis/repositories/e/qa/misc_files.cc
index 60b7857..b2c91e1 100644
--- a/paludis/repositories/e/qa/misc_files.cc
+++ b/paludis/repositories/e/qa/misc_files.cc
@@ -37,9 +37,6 @@ paludis::erepository::misc_files_check(
Log::get_instance()->message(ll_debug, lc_context) << "misc_files_check '"
<< dir << "', " << name << "'";
- if (! (dir / "ChangeLog").is_regular_file())
- reporter.message(QAMessage(dir / "ChangeLog", qaml_normal, name, "ChangeLog is missing or not a regular file"));
-
if (! (dir / "metadata.xml").is_regular_file())
reporter.message(QAMessage(dir / "metadata.xml", qaml_normal, name, "metadata.xml is missing or not a regular file"));
diff --git a/paludis/repositories/e/qa/misc_files_TEST.cc b/paludis/repositories/e/qa/misc_files_TEST.cc
index 2df3086..00130d2 100644
--- a/paludis/repositories/e/qa/misc_files_TEST.cc
+++ b/paludis/repositories/e/qa/misc_files_TEST.cc
@@ -70,25 +70,6 @@ namespace test_cases
}
} test_has_misc_files_check;
- struct HasMiscFilesCheckNoChangeLogTest : TestCase
- {
- HasMiscFilesCheckNoChangeLogTest() : TestCase("has misc files no ChangeLog") { }
-
- void run()
- {
- FSEntry e("misc_files_TEST_dir");
- TEST_CHECK(e.exists());
- TEST_CHECK(e.is_directory());
-
- FSEntry f1(e / "cat" / "no-changelog");
- TEST_CHECK(f1.exists());
-
- TestReporter r;
- TEST_CHECK(misc_files_check(r, f1, "misc_files"));
- TEST_CHECK_EQUAL(r.count, 1u);
- }
- } test_has_misc_files_check_no_changelog;
-
struct HasMiscFilesCheckNoMetadataTest : TestCase
{
HasMiscFilesCheckNoMetadataTest() : TestCase("has misc files no metadata.xml") { }
diff --git a/paludis/repositories/e/qa/misc_files_TEST_setup.sh b/paludis/repositories/e/qa/misc_files_TEST_setup.sh
index 4a5486a..ed3fb92 100755
--- a/paludis/repositories/e/qa/misc_files_TEST_setup.sh
+++ b/paludis/repositories/e/qa/misc_files_TEST_setup.sh
@@ -7,17 +7,12 @@ cd misc_files_TEST_dir || exit 3
mkdir "cat" || exit 4
mkdir "cat/yes" || exit 5
-touch "cat/yes/ChangeLog" "cat/yes/metadata.xml" || exit 6
+touch "cat/yes/metadata.xml" || exit 6
mkdir "cat/yes/files" || exit 7
-mkdir "cat/no-changelog" || exit 8
-touch "cat/no-changelog/metadata.xml" || exit 9
-mkdir "cat/no-changelog/files" || exit 10
-
mkdir "cat/no-metadata" || exit 8
-touch "cat/no-metadata/ChangeLog" || exit 9
mkdir "cat/no-metadata/files" || exit 10
mkdir "cat/bad-files" || exit 11
-touch "cat/bad-files/metadata.xml" "cat/bad-files/ChangeLog" "cat/bad-files/files"|| exit 12
+touch "cat/bad-files/metadata.xml" "cat/bad-files/files"|| exit 12
diff --git a/paludis/repositories/e/qa/qa_checks.cc b/paludis/repositories/e/qa/qa_checks.cc
index e6d59b9..8b027b3 100644
--- a/paludis/repositories/e/qa/qa_checks.cc
+++ b/paludis/repositories/e/qa/qa_checks.cc
@@ -24,6 +24,7 @@
#include <paludis/repositories/e/qa/stray_files.hh>
#include <paludis/repositories/e/qa/gpg.hh>
#include <paludis/repositories/e/qa/ebuild_count.hh>
+#include <paludis/repositories/e/qa/changelog.hh>
#include <paludis/repositories/e/qa/misc_files.hh>
#include <paludis/repositories/e/qa/files_dir_size.hh>
#include <paludis/repositories/e/qa/eapi_supported.hh>
@@ -104,6 +105,9 @@ QAChecks::QAChecks() :
_imp->package_dir_checks_group->add_check("ebuild_count",
tr1::bind(ebuild_count_check, _2, _1, _4, _5, "ebuild_count"));
+ _imp->package_dir_checks_group->add_check("changelog",
+ tr1::bind(changelog_check, _2, _1, _5, "changelog"));
+
_imp->package_dir_checks_group->add_check("misc_files",
tr1::bind(misc_files_check, _2, _1, "misc_files"));