Skip to content

Commit

Permalink
Merged #54 "Repository model ref list does not refresh on ref creatio…
Browse files Browse the repository at this point in the history
…n/deletion"
  • Loading branch information
gitblit committed May 7, 2014
2 parents 97b0bf2 + ce07c4f commit 4aa595c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions releases.moxie
Expand Up @@ -16,6 +16,7 @@ r23: {
- Fix forcing default locale to en or LANG_CC for web ui (ticket-51)
- Fix inconsistency with repository ownership permission checking (ticket-52)
- Prevent submission from New|Edit ticket page with empty titles (ticket-53)
- Ensure the repository model ref list is refreshed on ref creation or deletion (ticket-54)
- Fix case-sensitivity error in determining fork network (issue-420, ticket-62)
- Fix transport determination for SSH urls served on port 22 (issue-421, ticket-63)
changes:
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/gitblit/git/GitblitReceivePack.java
Expand Up @@ -331,6 +331,8 @@ public void onPostReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
return;
}

boolean isRefCreationOrDeletion = false;

// log ref changes
for (ReceiveCommand cmd : commands) {

Expand All @@ -339,9 +341,11 @@ public void onPostReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
switch (cmd.getType()) {
case DELETE:
LOGGER.info(MessageFormat.format("{0} DELETED {1} in {2} ({3})", user.username, cmd.getRefName(), repository.name, cmd.getOldId().name()));
isRefCreationOrDeletion = true;
break;
case CREATE:
LOGGER.info(MessageFormat.format("{0} CREATED {1} in {2}", user.username, cmd.getRefName(), repository.name));
isRefCreationOrDeletion = true;
break;
case UPDATE:
LOGGER.info(MessageFormat.format("{0} UPDATED {1} in {2} (from {3} to {4})", user.username, cmd.getRefName(), repository.name, cmd.getOldId().name(), cmd.getNewId().name()));
Expand All @@ -355,6 +359,10 @@ public void onPostReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
}
}

if (isRefCreationOrDeletion) {
gitblit.resetRepositoryCache(repository.name);
}

if (repository.useIncrementalPushTags) {
// tag each pushed branch tip
String emailAddress = user.emailAddress == null ? rp.getRefLogIdent().getEmailAddress() : user.emailAddress;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/gitblit/manager/GitblitManager.java
Expand Up @@ -928,6 +928,11 @@ public void resetRepositoryListCache() {
repositoryManager.resetRepositoryListCache();
}

@Override
public void resetRepositoryCache(String repositoryName) {
repositoryManager.resetRepositoryCache(repositoryName);
}

@Override
public List<String> getRepositoryList() {
return repositoryManager.getRepositoryList();
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/gitblit/manager/IRepositoryManager.java
Expand Up @@ -158,6 +158,14 @@ public interface IRepositoryManager extends IManager {
*/
void resetRepositoryListCache();

/**
* Reset all caches for this repository.
*
* @param repositoryName
* @since 1.5.1
*/
void resetRepositoryCache(String repositoryName);

/**
* Returns the list of all repositories available to Gitblit. This method
* does not consider user access permissions.
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/gitblit/manager/RepositoryManager.java
Expand Up @@ -454,6 +454,18 @@ private void clearRepositoryMetadataCache(String repositoryName) {
CommitCache.instance().clear(repositoryName);
}

/**
* Reset all caches for this repository.
*
* @param repositoryName
* @since 1.5.1
*/
@Override
public void resetRepositoryCache(String repositoryName) {
removeFromCachedRepositoryList(repositoryName);
clearRepositoryMetadataCache(repositoryName);
}

/**
* Resets the repository list cache.
*
Expand Down

0 comments on commit 4aa595c

Please sign in to comment.