File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
accuracy-snapshot-storage Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,12 @@ export class MongoDBSnapshotStorage implements AccuracySnapshotStorage {
4949 await this . snapshotCollection . insertOne ( snapshotWithMeta ) ;
5050 }
5151
52- async getLastRunIdForCommit ( commit : string ) : Promise < string | undefined > {
52+ async getLatestSnapshotsForCommit ( commit : string ) : Promise < AccuracySnapshotEntry [ ] > {
53+ const latestRunId = await this . getLastRunIdForCommit ( commit ) ;
54+ return latestRunId ? this . getSnapshotEntriesForRunId ( latestRunId ) : [ ] ;
55+ }
56+
57+ private async getLastRunIdForCommit ( commit : string ) : Promise < string | undefined > {
5358 const document = await this . snapshotCollection . findOne (
5459 { commit : commit } ,
5560 { sort : { createdOn : - 1 } , projection : { accuracyRunId : 1 } }
@@ -58,7 +63,7 @@ export class MongoDBSnapshotStorage implements AccuracySnapshotStorage {
5863 return document ?. accuracyRunId ? `${ document ?. accuracyRunId } ` : undefined ;
5964 }
6065
61- async getSnapshotEntriesForRunId ( accuracyRunId : string ) : Promise < AccuracySnapshotEntry [ ] > {
66+ private async getSnapshotEntriesForRunId ( accuracyRunId : string ) : Promise < AccuracySnapshotEntry [ ] > {
6267 const snapshotEntries = await this . snapshotCollection . find ( { accuracyRunId } ) . toArray ( ) ;
6368 return AccuracySnapshotEntrySchema . array ( ) . parse ( snapshotEntries ) ;
6469 }
Original file line number Diff line number Diff line change @@ -43,9 +43,7 @@ export interface AccuracySnapshotStorage {
4343 >
4444 ) : Promise < void > ;
4545
46- getLastRunIdForCommit ( commit : string ) : Promise < string | undefined > ;
47-
48- getSnapshotEntriesForRunId ( accuracyRunId : string ) : Promise < AccuracySnapshotEntry [ ] > ;
46+ getLatestSnapshotsForCommit ( commit : string ) : Promise < AccuracySnapshotEntry [ ] > ;
4947
5048 close ( ) : Promise < void > ;
5149}
Original file line number Diff line number Diff line change @@ -5,3 +5,8 @@ export async function getCommitSHA(): Promise<string | undefined> {
55 const lastCommit = commitLogs . latest ;
66 return lastCommit ?. hash ;
77}
8+
9+ export async function getMergeBase ( targetBranch : string , workBranchOrCommit : string ) : Promise < string > {
10+ const result = await simpleGit ( ) . raw ( [ "merge-base" , targetBranch , workBranchOrCommit ] ) ;
11+ return result . trim ( ) ;
12+ }
You can’t perform that action at this time.
0 commit comments