]> source.dussan.org Git - gitblit.git/commitdiff
Track fork's originRepository instead of parsing origin url (issue 190)
authorJames Moger <james.moger@gitblit.com>
Fri, 28 Jun 2013 14:20:00 +0000 (10:20 -0400)
committerJames Moger <james.moger@gitblit.com>
Fri, 28 Jun 2013 14:20:00 +0000 (10:20 -0400)
releases.moxie
src/main/java/com/gitblit/GitBlit.java

index 3fbc03c8221099e58703c025bae711bbe31e27e9..910fddc5e4e36a12cbccbed6c26ca5d4ac13da10 100644 (file)
@@ -35,6 +35,7 @@ r17: {
         - Fixed submodule diff display\r
 \r
        changes:\r
+        - Persist originRepository (for forks) in the repository config instead of relying on parsing origin urls which are susceptible to filesystem relocation (issue 190) \r
         - Improved error logging for servlet containers which provide a null contextFolder (issue 199)\r
         - Improve Gerrit change ref decoration in the refs panel (issue 206)\r
         - Display full commit message on commitdiff page (issue-258)\r
index bcfebb539885cc4299f2bc65a1db440b5c4c2103..1f9a9472d957896d78187d3b659a84f216b549f5 100644 (file)
@@ -1948,6 +1948,7 @@ public class GitBlit implements ServletContextListener {
                
                if (config != null) {
                        model.description = getConfig(config, "description", "");
+                       model.originRepository = getConfig(config, "originRepository", null);
                        model.addOwners(ArrayUtils.fromString(getConfig(config, "owner", "")));
                        model.useTickets = getConfig(config, "useTickets", false);
                        model.useDocs = getConfig(config, "useDocs", false);
@@ -2003,7 +2004,7 @@ public class GitBlit implements ServletContextListener {
                model.sparkleshareId = JGitUtils.getSparkleshareId(r);
                r.close();
                
-               if (model.origin != null && model.origin.startsWith("file://")) {
+               if (StringUtils.isEmpty(model.originRepository) && model.origin != null && model.origin.startsWith("file://")) {
                        // repository was cloned locally... perhaps as a fork
                        try {
                                File folder = new File(new URI(model.origin));
@@ -2412,6 +2413,7 @@ public class GitBlit implements ServletContextListener {
                                                        String origin = config.getString("remote", "origin", "url");
                                                        origin = origin.replace(repositoryName, repository.name);
                                                        config.setString("remote", "origin", "url", origin);
+                                                       config.setString(Constants.CONFIG_GITBLIT, null, "originRepository", repository.name);
                                                        config.save();
                                                } catch (Exception e) {
                                                        logger.error("Failed to update repository fork config for " + fork, e);
@@ -2420,11 +2422,12 @@ public class GitBlit implements ServletContextListener {
                                        }
                                }
                                
-                               // remove this repository from any origin model's fork list
+                               // update this repository's origin's fork list
                                if (!StringUtils.isEmpty(repository.originRepository)) {
                                        RepositoryModel origin = repositoryListCache.get(repository.originRepository);
                                        if (origin != null && !ArrayUtils.isEmpty(origin.forks)) {
                                                origin.forks.remove(repositoryName);
+                                               origin.forks.add(repository.name);
                                        }
                                }
 
@@ -2473,6 +2476,7 @@ public class GitBlit implements ServletContextListener {
        public void updateConfiguration(Repository r, RepositoryModel repository) {
                StoredConfig config = r.getConfig();
                config.setString(Constants.CONFIG_GITBLIT, null, "description", repository.description);
+               config.setString(Constants.CONFIG_GITBLIT, null, "originRepository", repository.originRepository);
                config.setString(Constants.CONFIG_GITBLIT, null, "owner", ArrayUtils.toString(repository.owners));
                config.setBoolean(Constants.CONFIG_GITBLIT, null, "useTickets", repository.useTickets);
                config.setBoolean(Constants.CONFIG_GITBLIT, null, "useDocs", repository.useDocs);