aboutsummaryrefslogtreecommitdiff
path: root/packages/server/src/api/git.ts
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-06-09 22:00:41 +0200
committerHampusM <hampus@hampusmat.com>2021-06-09 22:00:41 +0200
commitd7bfae93b9eeb39786900e22b024b54a678a8c60 (patch)
treec4dc18c97e9b5ac93f0168a5ca90b2544aaceebb /packages/server/src/api/git.ts
parentdf09cdac2e9962c899084b74fc29aea0bbd29e96 (diff)
The repository api endpoint includes whether or not the repository has a readme
Diffstat (limited to 'packages/server/src/api/git.ts')
-rw-r--r--packages/server/src/api/git.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/server/src/api/git.ts b/packages/server/src/api/git.ts
index 1f39692..9987bcf 100644
--- a/packages/server/src/api/git.ts
+++ b/packages/server/src/api/git.ts
@@ -392,4 +392,16 @@ export class Git {
return false;
}
}
+
+ async doesReadmeExist(repo_name) {
+ const full_repo_name = addRepoDirSuffix(repo_name);
+ const repo = await Repository.openBare(`${this.base_dir}/${full_repo_name}`);
+
+ const master_commit = await repo.getMasterCommit();
+ const tree = await master_commit.getTree();
+
+ const readme = await tree.getEntry("README.md").catch(() => null);
+
+ return Boolean(readme);
+ }
}; \ No newline at end of file