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 {
49
49
await this . snapshotCollection . insertOne ( snapshotWithMeta ) ;
50
50
}
51
51
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 > {
53
58
const document = await this . snapshotCollection . findOne (
54
59
{ commit : commit } ,
55
60
{ sort : { createdOn : - 1 } , projection : { accuracyRunId : 1 } }
@@ -58,7 +63,7 @@ export class MongoDBSnapshotStorage implements AccuracySnapshotStorage {
58
63
return document ?. accuracyRunId ? `${ document ?. accuracyRunId } ` : undefined ;
59
64
}
60
65
61
- async getSnapshotEntriesForRunId ( accuracyRunId : string ) : Promise < AccuracySnapshotEntry [ ] > {
66
+ private async getSnapshotEntriesForRunId ( accuracyRunId : string ) : Promise < AccuracySnapshotEntry [ ] > {
62
67
const snapshotEntries = await this . snapshotCollection . find ( { accuracyRunId } ) . toArray ( ) ;
63
68
return AccuracySnapshotEntrySchema . array ( ) . parse ( snapshotEntries ) ;
64
69
}
Original file line number Diff line number Diff line change @@ -43,9 +43,7 @@ export interface AccuracySnapshotStorage {
43
43
>
44
44
) : Promise < void > ;
45
45
46
- getLastRunIdForCommit ( commit : string ) : Promise < string | undefined > ;
47
-
48
- getSnapshotEntriesForRunId ( accuracyRunId : string ) : Promise < AccuracySnapshotEntry [ ] > ;
46
+ getLatestSnapshotsForCommit ( commit : string ) : Promise < AccuracySnapshotEntry [ ] > ;
49
47
50
48
close ( ) : Promise < void > ;
51
49
}
Original file line number Diff line number Diff line change @@ -5,3 +5,8 @@ export async function getCommitSHA(): Promise<string | undefined> {
5
5
const lastCommit = commitLogs . latest ;
6
6
return lastCommit ?. hash ;
7
7
}
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