- Gitblit-as-viewer with no repository urls failed to display summary page (issue 269)
- Fixed missing model class dependencies in Gitblit Manager build
- Fix for IE10 compatability mode
+ - Reset dashboard and activity commit cache on branch REWIND or DELETE
changes: ~
additions: ~
dependencyChanges: ~
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
\r
+import com.gitblit.Constants;\r
import com.gitblit.Constants.AccessRestrictionType;\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
import com.gitblit.models.UserModel;\r
import com.gitblit.utils.ArrayUtils;\r
import com.gitblit.utils.ClientLogger;\r
+import com.gitblit.utils.CommitCache;\r
import com.gitblit.utils.JGitUtils;\r
import com.gitblit.utils.RefLogUtils;\r
import com.gitblit.utils.StringUtils;\r
return;\r
}\r
}\r
+ \r
+ // reset branch commit cache on REWIND and DELETE\r
+ for (ReceiveCommand cmd : commands) {\r
+ String ref = cmd.getRefName();\r
+ if (ref.startsWith(Constants.R_HEADS)) {\r
+ switch (cmd.getType()) {\r
+ case UPDATE_NONFASTFORWARD:\r
+ case DELETE:\r
+ CommitCache.instance().clear(repository.name, ref);\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ }\r
\r
Set<String> scripts = new LinkedHashSet<String>();\r
scripts.addAll(GitBlit.self().getPreReceiveScriptsInherited(repository));\r
}
}
+ /**
+ * Clears the commit cache for a specific branch of a specific repository.
+ *
+ * @param repositoryName
+ * @param branch
+ */
+ public void clear(String repositoryName, String branch) {
+ String repoKey = repositoryName.toLowerCase();
+ ObjectCache<List<RepositoryCommit>> repoCache = cache.get(repoKey);
+ if (repoCache != null) {
+ List<RepositoryCommit> commits = repoCache.remove(branch.toLowerCase());
+ if (!ArrayUtils.isEmpty(commits)) {
+ logger.info(MessageFormat.format("{0}:{1} commit cache cleared", repositoryName, branch));
+ }
+ }
+ }
+
/**
* Get all commits for the specified repository:branch that are in the cache.
*