From e8a16c9a47eef7c625686d2a868ec91d05fd95c5 Mon Sep 17 00:00:00 2001 From: Modestas Vainius Date: Sun, 24 Apr 2011 22:25:57 +0300 Subject: Support 'description' field in the create repository rule. Its value is used to fill in repository/description file used by gitweb. --- src/repository.cpp | 9 +++++++++ src/ruleparser.cpp | 4 ++++ src/ruleparser.h | 1 + 3 files changed, 14 insertions(+) diff --git a/src/repository.cpp b/src/repository.cpp index e6ea81c..abf0b21 100644 --- a/src/repository.cpp +++ b/src/repository.cpp @@ -84,6 +84,15 @@ Repository::Repository(const Rules::Repository &rule) init.setWorkingDirectory(name); init.start("git", QStringList() << "--bare" << "init"); init.waitForFinished(-1); + // Write description + if (!rule.description.isEmpty()) { + QFile fDesc(QDir(name).filePath("description")); + if (fDesc.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { + fDesc.write(rule.description.toUtf8()); + fDesc.putChar('\n'); + fDesc.close(); + } + } { QFile marks(name + "/" + marksFileName(name)); marks.open(QIODevice::WriteOnly); diff --git a/src/ruleparser.cpp b/src/ruleparser.cpp index eb309bf..849a13f 100644 --- a/src/ruleparser.cpp +++ b/src/ruleparser.cpp @@ -93,6 +93,7 @@ void Rules::load(const QString &filename) QRegExp matchLine("match\\s+(.*)", Qt::CaseInsensitive); QRegExp matchActionLine("action\\s+(\\w+)", Qt::CaseInsensitive); QRegExp matchRepoLine("repository\\s+(\\S+)", Qt::CaseInsensitive); + QRegExp matchDescLine("description\\s+(.+)$", Qt::CaseInsensitive); QRegExp matchBranchLine("branch\\s+(\\S+)", Qt::CaseInsensitive); QRegExp matchRevLine("(min|max) revision (\\d+)", Qt::CaseInsensitive); QRegExp matchAnnotateLine("annotated\\s+(\\S+)", Qt::CaseInsensitive); @@ -152,6 +153,9 @@ void Rules::load(const QString &filename) repo.branches += branch; continue; + } else if (matchDescLine.exactMatch(line)) { + repo.description = matchDescLine.cap(1); + continue; } else if (matchRepoLine.exactMatch(line)) { repo.forwardTo = matchRepoLine.cap(1); continue; diff --git a/src/ruleparser.h b/src/ruleparser.h index 9d21937..5eaba49 100644 --- a/src/ruleparser.h +++ b/src/ruleparser.h @@ -43,6 +43,7 @@ public: QString name; QList branches; + QString description; QString forwardTo; QString prefix; -- cgit v1.2.1