-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): include commit info in report.json
- Loading branch information
1 parent
66949c2
commit 5965900
Showing
25 changed files
with
235 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { z } from 'zod'; | ||
|
||
export const commitSchema = z.object( | ||
{ | ||
hash: z | ||
.string({ description: 'Commit SHA (full)' }) | ||
.regex( | ||
/^[\da-f]{40}$/, | ||
'Commit SHA should be a 40-character hexadecimal string', | ||
), | ||
message: z.string({ description: 'Commit message' }), | ||
date: z.coerce.date({ | ||
description: 'Date and time when commit was authored', | ||
}), | ||
author: z | ||
.string({ | ||
description: 'Commit author name', | ||
}) | ||
.trim(), | ||
}, | ||
{ description: 'Git commit' }, | ||
); | ||
|
||
export type Commit = z.infer<typeof commitSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { type Commit, commitSchema } from './commit'; | ||
|
||
describe('commitSchema', () => { | ||
it('should accept valid git commit data', () => { | ||
expect(() => | ||
commitSchema.parse({ | ||
hash: 'abcdef0123456789abcdef0123456789abcdef01', | ||
message: 'Minor fixes', | ||
author: 'John Doe', | ||
date: new Date(), | ||
} satisfies Commit), | ||
).not.toThrow(); | ||
}); | ||
|
||
it('should coerce date string into Date object', () => { | ||
expect( | ||
commitSchema.parse({ | ||
hash: 'abcdef0123456789abcdef0123456789abcdef01', | ||
message: 'Minor fixes', | ||
author: 'John Doe', | ||
date: '2024-03-06T17:30:12+01:00', | ||
}), | ||
).toEqual<Commit>({ | ||
hash: 'abcdef0123456789abcdef0123456789abcdef01', | ||
message: 'Minor fixes', | ||
author: 'John Doe', | ||
date: new Date('2024-03-06T17:30:12+01:00'), | ||
}); | ||
}); | ||
|
||
it('should throw for invalid hash', () => { | ||
expect(() => | ||
commitSchema.parse({ | ||
hash: '12345678', // too short | ||
message: 'Minor fixes', | ||
author: 'John Doe', | ||
date: new Date(), | ||
} satisfies Commit), | ||
).toThrow('Commit SHA should be a 40-character hexadecimal string'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.