aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-04 09:17:01 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-04 09:17:01 +0000
commit394b0606f7ecce124987db730d1d3162c6ad510f (patch)
treeb58f53a2b794d3d026bf39677759b72fc3327329
parent0af528e3f1a1a65e593f2cd8bd4c974e059ac84c (diff)
downloadpaludis-394b0606f7ecce124987db730d1d3162c6ad510f.tar.gz
paludis-394b0606f7ecce124987db730d1d3162c6ad510f.tar.xz
More QA work
-rw-r--r--paludis/repositories/e/qa/Makefile.am4
-rw-r--r--paludis/repositories/e/qa/qa_checks.cc4
-rw-r--r--paludis/repositories/e/qa/repo_name.cc47
-rw-r--r--paludis/repositories/e/qa/repo_name.hh15
4 files changed, 68 insertions, 2 deletions
diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am
index 3f52279..d9a99c3 100644
--- a/paludis/repositories/e/qa/Makefile.am
+++ b/paludis/repositories/e/qa/Makefile.am
@@ -38,7 +38,8 @@ paludis_repositories_e_include_HEADERS = \
stray_files.hh \
kv_variables.hh \
visibility.hh \
- whitespace.hh
+ whitespace.hh \
+ repo_name.hh
lib_LTLIBRARIES = libpaludiserepositoryqa.la
@@ -56,6 +57,7 @@ libpaludiserepositoryqa_la_SOURCES = \
kv_variables.cc \
visibility.cc \
whitespace.cc \
+ repo_name.cc \
$(paludis_repositories_e_include_HEADERS)
libpaludiserepositoryqa_la_LDFLAGS = \
diff --git a/paludis/repositories/e/qa/qa_checks.cc b/paludis/repositories/e/qa/qa_checks.cc
index f672e98..1ce31ec 100644
--- a/paludis/repositories/e/qa/qa_checks.cc
+++ b/paludis/repositories/e/qa/qa_checks.cc
@@ -30,6 +30,7 @@
#include <paludis/repositories/e/qa/visibility.hh>
#include <paludis/repositories/e/qa/kv_variables.hh>
#include <paludis/repositories/e/qa/whitespace.hh>
+#include <paludis/repositories/e/qa/repo_name.hh>
using namespace paludis;
using namespace paludis::erepository;
@@ -64,6 +65,9 @@ QAChecks::QAChecks() :
_imp->tree_checks_group->add_check("stray_tree_files",
tr1::bind(stray_files_check, _2, _4, _5, is_stray_at_tree_dir, "stray_tree_files"));
+ _imp->tree_checks_group->add_check("repo_name",
+ tr1::bind(repo_name_check, _2, _1, "repo_name"));
+
_imp->category_dir_checks_group->add_check("stray_category_dir_files",
tr1::bind(stray_files_check, _2, _4, _5, is_stray_at_category_dir, "stray_category_dir_files"));
diff --git a/paludis/repositories/e/qa/repo_name.cc b/paludis/repositories/e/qa/repo_name.cc
index dd53f82..a8d2c84 100644
--- a/paludis/repositories/e/qa/repo_name.cc
+++ b/paludis/repositories/e/qa/repo_name.cc
@@ -18,4 +18,51 @@
*/
#include "repo_name.hh"
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/repository.hh>
+#include <paludis/qa.hh>
+#include <fstream>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+bool
+paludis::erepository::repo_name_check(
+ QAReporter & reporter,
+ const FSEntry & dir,
+ const std::string & name)
+{
+ if (! (dir / "profiles" / "repo_name").exists())
+ reporter.message(QAMessage(dir / "profiles" / "repo_name", qaml_normal, name, "No 'profiles/repo_name' file"));
+ else
+ {
+ std::ifstream f(stringify(dir / "profiles" / "repo_name").c_str());
+ if (! f)
+ reporter.message(QAMessage(dir / "profiles" / "repo_name", qaml_normal, name, "repo_name file unreadable"));
+ else
+ {
+ std::string line;
+ if (! std::getline(f, line))
+ reporter.message(QAMessage(dir / "profiles" / "repo_name", qaml_normal, name, "repo_name file empty"));
+ else
+ {
+ try
+ {
+ RepositoryName n(line);
+ }
+ catch (const RepositoryNameError & e)
+ {
+ reporter.message(QAMessage(dir / "profiles" / "repo_name", qaml_normal, name,
+ "repo_name not a valid repository name"));
+ }
+
+ if (std::getline(f, line))
+ reporter.message(QAMessage(dir / "profiles" / "repo_name", qaml_normal, name, "repo_name has trailing content"));
+ }
+ }
+ }
+
+ return true;
+}
diff --git a/paludis/repositories/e/qa/repo_name.hh b/paludis/repositories/e/qa/repo_name.hh
index fd1f15b..168837d 100644
--- a/paludis/repositories/e/qa/repo_name.hh
+++ b/paludis/repositories/e/qa/repo_name.hh
@@ -20,6 +20,19 @@
#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_REPO_NAME_HH
#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_REPO_NAME_HH 1
-#include "config.h"
+#include <paludis/repositories/e/qa/qa_controller.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ bool repo_name_check(
+ QAReporter &,
+ const FSEntry & dir,
+ const std::string & s
+ );
+ }
+}
+
#endif