Florian Zschocke
2013-08-21 acb5bdf953e4242c175b22b4ddd2197079ee6ace
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 files modified
17 ■■■■■ changed files
src/main/java/com/gitblit/GitBlit.java 17 ●●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/GitBlit.java
@@ -2021,6 +2021,14 @@
        boolean hasOrigin = !StringUtils.isEmpty(config.getString("remote", "origin", "url"));
        
        if (config != null) {
            // Initialize description from description file
            if (getConfig(config,"description", null) == null) {
                File descFile = new File(r.getDirectory(), "description");
                if (descFile.exists()) {
                    config.setString(Constants.CONFIG_GITBLIT, null, "description",
                            com.gitblit.utils.FileUtils.readContent(descFile, System.getProperty("line.separator")));
                }
            }
            model.description = getConfig(config, "description", "");
            model.originRepository = getConfig(config, "originRepository", null);
            model.addOwners(ArrayUtils.fromString(getConfig(config, "owner", "")));
@@ -2521,6 +2529,15 @@
        // update settings
        if (r != null) {
            updateConfiguration(r, repository);
            // Update the description file
            File descFile = new File(r.getDirectory(), "description");
            if (repository.description != null)
            {
                com.gitblit.utils.FileUtils.writeContent(descFile, repository.description);
            }
            else if (descFile.exists() && !descFile.isDirectory()) {
                descFile.delete();
            }
            // only update symbolic head if it changes
            String currentRef = JGitUtils.getHEADRef(r);
            if (!StringUtils.isEmpty(repository.HEAD) && !repository.HEAD.equals(currentRef)) {