Skip to content

Commit acb5bdf

Browse files
committed
Maintain repository 'description' file.
Make use of the 'description' file in Git repositories which is used by tools like gitweb or cgit and often by standard hooks. Update the file when changing the description and initialize the Gitblit description from the file when Gitblit reads a new, existing repository.
1 parent e05f226 commit acb5bdf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/main/java/com/gitblit/GitBlit.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,14 @@ private RepositoryModel loadRepositoryModel(String repositoryName) {
20212021
boolean hasOrigin = !StringUtils.isEmpty(config.getString("remote", "origin", "url"));
20222022

20232023
if (config != null) {
2024+
// Initialize description from description file
2025+
if (getConfig(config,"description", null) == null) {
2026+
File descFile = new File(r.getDirectory(), "description");
2027+
if (descFile.exists()) {
2028+
config.setString(Constants.CONFIG_GITBLIT, null, "description",
2029+
com.gitblit.utils.FileUtils.readContent(descFile, System.getProperty("line.separator")));
2030+
}
2031+
}
20242032
model.description = getConfig(config, "description", "");
20252033
model.originRepository = getConfig(config, "originRepository", null);
20262034
model.addOwners(ArrayUtils.fromString(getConfig(config, "owner", "")));
@@ -2521,6 +2529,15 @@ public void updateRepositoryModel(String repositoryName, RepositoryModel reposit
25212529
// update settings
25222530
if (r != null) {
25232531
updateConfiguration(r, repository);
2532+
// Update the description file
2533+
File descFile = new File(r.getDirectory(), "description");
2534+
if (repository.description != null)
2535+
{
2536+
com.gitblit.utils.FileUtils.writeContent(descFile, repository.description);
2537+
}
2538+
else if (descFile.exists() && !descFile.isDirectory()) {
2539+
descFile.delete();
2540+
}
25242541
// only update symbolic head if it changes
25252542
String currentRef = JGitUtils.getHEADRef(r);
25262543
if (!StringUtils.isEmpty(repository.HEAD) && !repository.HEAD.equals(currentRef)) {

0 commit comments

Comments
 (0)