Skip to content

Commit

Permalink
Propagate exception on item history retrieval. Stop history traversal…
Browse files Browse the repository at this point in the history
… at file creation (last creation of a file in the path) (#3677)
  • Loading branch information
jmendeza authored Dec 12, 2024
1 parent cba0da2 commit b8114fa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void forAllSitePaths(String siteId,
* @throws IOException if there is any error reading the git log or getting diffs between commits
* @throws GitAPIException if there is any error while executing git commands
*/
List<ItemVersion> getContentItemHistory(String site, String path) throws IOException, GitAPIException;
List<ItemVersion> getContentItemHistory(String site, String path) throws IOException, GitAPIException, ServiceLayerException;

/**
* Get the commits between two commit ids.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,10 @@ public List<ItemVersion> getContentItemHistory(String site, String path) throws
// Set this after the diff entry is retrieved, so that the old path is set correctly
version.setOldPath(prependIfMissing(currentPath, FILE_SEPARATOR));
versionHistory.add(version);
if (currentPath == null) {
// We have reached the latest creation of a file in this path
break;
}
}
} finally {
generalLockService.unlock(repoLockKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public VersionTO[] getContentVersionHistory(String site, String path) {
}

@Override
public List<ItemVersion> getContentItemHistory(String site, String path) {
public List<ItemVersion> getContentItemHistory(String site, String path) throws GitAPIException, ServiceLayerException, IOException {
logger.debug("Get version history for site '{}' path '{}'", site, path);
try {
if (pointersExist(site, path)) {
Expand All @@ -390,7 +390,7 @@ public List<ItemVersion> getContentItemHistory(String site, String path) {
return localRepositoryV2.getContentItemHistory(site, path);
} catch (Exception e) {
logger.error("Failed to get version history for site '{}' path '{}'", site, path, e);
return null;
throw e;
}
}

Expand Down

0 comments on commit b8114fa

Please sign in to comment.