From 4a4eea5e918cf86a1bf647cd5d36161c8891acf6 Mon Sep 17 00:00:00 2001 From: Lars Hampe Date: Fri, 25 Oct 2024 19:50:21 +0200 Subject: [PATCH] wip: cli git parsing --- apps/cli/src/utils/git_log.ts | 36 ++++++----------------------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/apps/cli/src/utils/git_log.ts b/apps/cli/src/utils/git_log.ts index a82b7f9..44621e8 100644 --- a/apps/cli/src/utils/git_log.ts +++ b/apps/cli/src/utils/git_log.ts @@ -1,18 +1,8 @@ -const GITFORMAT = `--pretty=format:{ - "commit": "%h", - "parent": "%p", - "refs": "%D", - "subject": "%s", - "notes": "%N", - "body": "%b", - "author": { "name": "%aN", "email": "%aE", "date": "%ad" }, - "commiter": { "name": "%cN", "email": "%cE", "date": "%cd" } - },` +const GITFORMAT = `--pretty=format:{%n "commit": "%h",%n "parent": "%p",%n "refs": "%D",%n "subject": "%s",%n "notes": "%N",%n "body": "%b",%n "author": { "name": "%aN", "email": "%aE", "date": "%ad" },%n "commiter": { "name": "%cN", "email": "%cE", "date": "%cd" }%n},` export const git_log = async ( from: string | undefined, to = 'HEAD', - // biome-ignore lint/suspicious/noExplicitAny: -): Promise => { +): Promise => { // https://git-scm.com/docs/pretty-formats const r = await Bun.spawn([ 'git', @@ -24,22 +14,8 @@ export const git_log = async ( '--date=iso', ]) const text = await new Response(r.stdout).text() - console.log(text) - r /* eturn text - .split('----\n') - .splice(1) - .map((line) => { - const [firstLine, , ..._body] = line.split('\n') - const [message, shortHash, authorName, date, authorEmail] = - firstLine.split('|') - // biome-ignore lint/suspicious/noExplicitAny: - const r: any = { - date, - message, - shortHash, - author: { name: authorName, email: authorEmail }, - body: _body.join('\n'), - } - return r - }) */ + // console.log(JSON.parse('[' + text.slice(0, -1) + ']')) + // const str = JSON.stringify(`[${text.slice(0, -1)}]`) + // console.log(JSON.parse(str)) + return false }