@@ -84,56 +84,53 @@ const getRepositoryDetailsView: ReqHandler = async (request, reply) => {
};
const reqHandler = reply.makeRequestHandler(request, reply);
+ const props = {
+ branches,
+ currentRef,
+ currentUser,
+ cloneUrl,
+ lastCommit,
+ parentOrg,
+ path,
+ readmeFileContent,
+ repo,
+ repoHead: null,
+ repoFiles: [],
+ tags,
+ } as Omit<RepositoryDetailsViewProps, "commonProps">;
try {
- const repoHead = await repoService.getRepositoryHead(repo, currentRef);
- const repoFiles = await repoService.getRepositoryFiles(
- repo,
- "",
- currentRef
- );
-
- return reqHandler<RepositoryDetailsViewProps>(RepositoryDetailsView.name, {
- branches,
- currentRef,
- currentUser,
- cloneUrl,
- lastCommit,
- parentOrg,
- path,
- readmeFileContent,
- repo,
- repoHead,
- repoFiles,
- tags,
- });
+ props.repoHead = await repoService.getRepositoryHead(repo, currentRef);
} catch (err) {
const error = err as Error;
if (error.message.includes(`${currentRef} is not a valid object name`)) {
return reqHandler<RepositoryDetailsViewProps>(
RepositoryDetailsView.name,
- {
- branches,
- currentRef,
- currentUser,
- cloneUrl,
- parentOrg,
- path,
- readmeFileContent,
- repo,
- repoHead: null,
- repoFiles: [],
- tags,
- }
+ props
);
} else if (
error.message.includes("Could not find a valid git repository")
) {
return reply.status(404).callNotFound();
} else {
- throw err;
+ console.log(`Could not get repo head. Error: ${error.message}`);
}
}
+
+ try {
+ props.repoFiles = await repoService.getRepositoryFiles(
+ repo,
+ "",
+ currentRef
+ );
+ } catch (err) {
+ console.log(`Could not get repo files. Error: ${(err as Error).message}`);
+ }
+
+ return reqHandler<RepositoryDetailsViewProps>(
+ RepositoryDetailsView.name,
+ props
+ );
};
export default getRepositoryDetailsView;