Skip to content

Commit e8a16c9

Browse files
committed
Support 'description' field in the create repository rule.
Its value is used to fill in repository/description file used by gitweb.
1 parent 197979b commit e8a16c9

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/repository.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ Repository::Repository(const Rules::Repository &rule)
8484
init.setWorkingDirectory(name);
8585
init.start("git", QStringList() << "--bare" << "init");
8686
init.waitForFinished(-1);
87+
// Write description
88+
if (!rule.description.isEmpty()) {
89+
QFile fDesc(QDir(name).filePath("description"));
90+
if (fDesc.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
91+
fDesc.write(rule.description.toUtf8());
92+
fDesc.putChar('\n');
93+
fDesc.close();
94+
}
95+
}
8796
{
8897
QFile marks(name + "/" + marksFileName(name));
8998
marks.open(QIODevice::WriteOnly);

src/ruleparser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ void Rules::load(const QString &filename)
9393
QRegExp matchLine("match\\s+(.*)", Qt::CaseInsensitive);
9494
QRegExp matchActionLine("action\\s+(\\w+)", Qt::CaseInsensitive);
9595
QRegExp matchRepoLine("repository\\s+(\\S+)", Qt::CaseInsensitive);
96+
QRegExp matchDescLine("description\\s+(.+)$", Qt::CaseInsensitive);
9697
QRegExp matchBranchLine("branch\\s+(\\S+)", Qt::CaseInsensitive);
9798
QRegExp matchRevLine("(min|max) revision (\\d+)", Qt::CaseInsensitive);
9899
QRegExp matchAnnotateLine("annotated\\s+(\\S+)", Qt::CaseInsensitive);
@@ -152,6 +153,9 @@ void Rules::load(const QString &filename)
152153

153154
repo.branches += branch;
154155
continue;
156+
} else if (matchDescLine.exactMatch(line)) {
157+
repo.description = matchDescLine.cap(1);
158+
continue;
155159
} else if (matchRepoLine.exactMatch(line)) {
156160
repo.forwardTo = matchRepoLine.cap(1);
157161
continue;

src/ruleparser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class Rules
4343

4444
QString name;
4545
QList<Branch> branches;
46+
QString description;
4647

4748
QString forwardTo;
4849
QString prefix;

0 commit comments

Comments
 (0)