Skip to content

Commit 0c8343b

Browse files
[server] Fix order of commits in MockRepositoryProvider to be aligned with actual implementation
Co-authored-by: Filip Troníček <[email protected]>
1 parent b5a3429 commit 0c8343b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

components/server/src/workspace/context-service.spec.db.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class MockRepositoryProvider implements RepositoryProvider {
9292
if (!b) {
9393
throw new Error("branch not found");
9494
}
95-
b.commits.push(commit);
95+
b.commits.unshift(commit);
9696
}
9797

9898
async hasReadAccess(user: any, owner: string, repo: string): Promise<boolean> {
@@ -123,8 +123,8 @@ class MockRepositoryProvider implements RepositoryProvider {
123123
for (const b of this.branches.values()) {
124124
for (const [i, c] of b.commits.entries()) {
125125
if (c.sha === ref) {
126-
// this commit, and everything before it
127-
return b.commits.slice(0, i).map((c) => c.sha);
126+
// everything before `ref`
127+
return b.commits.slice(i + 1).map((c) => c.sha);
128128
}
129129
}
130130
}
@@ -150,14 +150,14 @@ function headu<T>(arr: T[] | undefined): T | undefined {
150150
if (!arr || arr.length === 0) {
151151
return undefined;
152152
}
153-
return arr[arr.length - 1];
153+
return arr[0];
154154
}
155155

156156
function head<T>(arr: T[]): T {
157157
if (arr.length === 0) {
158158
throw new Error("empty array");
159159
}
160-
return arr[arr.length - 1];
160+
return arr[0];
161161
}
162162

163163
const SNAPSHOT_BUCKET = "https://gitpod.io/none-bucket";

0 commit comments

Comments
 (0)