James Moger
2012-08-03 f3ff376a5eb945f15329b66bbb7d69ed3ca2ce3f
Confirmed fix for GO settings manipulation (issue-85)
2 files modified
9 ■■■■ changed files
docs/04_releases.mkd 1 ●●●● patch | view | raw | blame | history
src/com/gitblit/FileSettings.java 8 ●●●● patch | view | raw | blame | history
docs/04_releases.mkd
@@ -16,6 +16,7 @@
- Output real RAW content, not simulated RAW content (issue 114)
- Fixed Lucene charset encoding bug when reindexing a repository (issue 112)
- Fixed null pointer in LdapUserSerivce if account has a null email address (issue 110)
- Really fixed failure to update a GO setting from the manager (issue 85)
#### additions
src/com/gitblit/FileSettings.java
@@ -87,8 +87,14 @@
        String content = FileUtils.readContent(propertiesFile, "\n");
        for (Map.Entry<String, String> setting:settings.entrySet()) {
            String regex = "(?m)^(" + regExEscape(setting.getKey()) + "\\s*+=\\s*+)"
                    + "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
                    + "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
            String oldContent = content;
            content = content.replaceAll(regex, setting.getKey() + " = " + setting.getValue());
            if (content.equals(oldContent)) {
                // did not replace value because it does not exist in the file
                // append new setting to content (issue-85)
                content += "\n" + setting.getKey() + " = " + setting.getValue();
            }
        }
        FileUtils.writeContent(propertiesFile, content);
        // manually set the forceReload flag because not all JVMs support real