Skip to content

Commit b8121af

Browse files
authored
fix: use git show instead of git log (#118)
git log showed all commits to the given commit and hence was running out of memory
1 parent d8fecf4 commit b8121af

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/adapter.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ export interface TableRow {
3030
id: number
3131
name: string
3232
type: TaskType
33-
commit: string
33+
commit: string | null
3434
head: string
35-
applied_at: Date
35+
applied_at: Date | null
3636
}
3737

3838
export abstract class DbAdapter {
@@ -85,9 +85,9 @@ export abstract class DbAdapter {
8585
id: row.id,
8686
type: row.type,
8787
migration: new Migration(row.name),
88-
commit: new Commit({ sha1: row.commit }),
88+
commit: row.commit ? new Commit({ sha1: row.commit }) : undefined,
8989
head: new Commit({ sha1: row.head }),
90-
appliedAt: row.applied_at,
90+
appliedAt: row.applied_at || undefined,
9191
})
9292
return task
9393
}

src/adapters/postgres.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class PostgresAdapter extends DbAdapter {
3434
CREATE TABLE IF NOT EXISTS "merkel_meta" (
3535
"id" SERIAL NOT NULL PRIMARY KEY,
3636
"name" TEXT NOT NULL,
37-
"type" merkel_migration_type,
37+
"type" merkel_migration_type NOT NULL,
3838
"commit" TEXT,
3939
"head" TEXT NOT NULL,
4040
"applied_at" TIMESTAMP WITH TIME ZONE

src/git.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class Commit {
5454
*/
5555
public async loadSubject(): Promise<void> {
5656
if (this.message === undefined) {
57-
const [stdout] = await execFile('git', ['log', '--format=%B', this.sha1])
57+
const [stdout] = await execFile('git', ['show', '--format=%B', this.sha1])
5858
this.message = stdout.toString()
5959
}
6060
}

0 commit comments

Comments
 (0)