diff --git a/web/src/lib/api/repo.ts b/web/src/lib/api/repo.ts
index 930e09f9..83048848 100644
--- a/web/src/lib/api/repo.ts
+++ b/web/src/lib/api/repo.ts
@@ -108,6 +108,9 @@ const splitMessage = (message: string): [string, string] => {
return [message.slice(0, separator).trim(), message.slice(separator + 2).trim()];
};
+/** the subject is the first paragraph, not the first line */
+export const subjectOf = (message: string): string => splitMessage(message)[0];
+
export const toCommitSummary = (commit: LogCommit): CommitSummary => {
const [subject, body] = splitMessage(commit.message ?? "");
const hash = commit.this ?? "";
@@ -123,6 +126,21 @@ export const toCommitSummary = (commit: LogCommit): CommitSummary => {
};
};
+// the tree endpoint uses lexicon casing where the log ones pass through go field
+// names, so this cannot share `toCommitSummary`
+export const toTreeCommitSummary = (commit: Tree.LastCommit): CommitSummary => {
+ const [subject, body] = splitMessage(commit.message ?? "");
+ return {
+ hash: commit.hash,
+ shortHash: commit.hash.slice(0, 8),
+ subject,
+ body,
+ authorName: commit.author?.name ?? "",
+ authorEmail: commit.author?.email ?? "",
+ when: commit.when ?? commit.author?.when ?? ""
+ };
+};
+
export interface BranchSummary {
name: string;
hash: string;
diff --git a/web/src/lib/components/repo/FileTree.stories.svelte b/web/src/lib/components/repo/FileTree.stories.svelte
new file mode 100644
index 00000000..67026d88
--- /dev/null
+++ b/web/src/lib/components/repo/FileTree.stories.svelte
@@ -0,0 +1,44 @@
+
+
+