Skip to content

Commit 1cca717

Browse files
committed
Fixes date ordering of pseudo commits
1 parent 72d1f24 commit 1cca717

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/env/node/git/sub-providers/commits.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export class CommitsGitSubProvider implements GitCommitsSubProvider {
6565
this.container,
6666
repoPath,
6767
rev,
68+
new Date(),
6869
await this.provider.config.getCurrentUser(repoPath),
6970
);
7071
}

src/git/models/statusFile.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class GitStatusFile implements GitFile {
127127
}
128128

129129
getPseudoCommits(container: Container, user: GitUser | undefined): GitCommit[] {
130-
const now = new Date();
130+
let now = new Date();
131131

132132
if (this.conflicted) {
133133
const file = new GitFileChange(
@@ -141,7 +141,7 @@ export class GitStatusFile implements GitFile {
141141
false,
142142
);
143143
return [
144-
createUncommittedChangesCommit(container, this.repoPath, uncommitted, user, {
144+
createUncommittedChangesCommit(container, this.repoPath, uncommitted, now, user, {
145145
files: { file: file, files: [file] },
146146
parents: ['HEAD'],
147147
}),
@@ -164,14 +164,14 @@ export class GitStatusFile implements GitFile {
164164
false,
165165
);
166166
commits.push(
167-
createUncommittedChangesCommit(container, this.repoPath, uncommitted, user, {
167+
createUncommittedChangesCommit(container, this.repoPath, uncommitted, now, user, {
168168
files: { file: file, files: [file] },
169169
parents: [previousSha],
170170
}),
171171
);
172172

173173
// Decrements the date to guarantee the staged entry (if exists) will be sorted after the working entry (most recent first)
174-
now.setMilliseconds(now.getMilliseconds() - 1);
174+
now = new Date(now.getTime() - 60000);
175175
}
176176

177177
if (staged) {
@@ -186,7 +186,7 @@ export class GitStatusFile implements GitFile {
186186
true,
187187
);
188188
commits.push(
189-
createUncommittedChangesCommit(container, this.repoPath, uncommittedStaged, user, {
189+
createUncommittedChangesCommit(container, this.repoPath, uncommittedStaged, now, user, {
190190
files: { file: file, files: [file] },
191191
parents: ['HEAD'],
192192
}),

src/git/utils/-webview/commit.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ export function createUncommittedChangesCommit(
99
container: Container,
1010
repoPath: string,
1111
sha: string,
12+
now: Date,
1213
user: GitUser | undefined,
1314
options?: {
1415
files?: GitFileChange | GitFileChange[] | { file?: GitFileChange; files?: GitFileChange[] } | undefined;
1516
parents?: string[];
1617
stats?: GitCommitStats;
1718
},
1819
): GitCommit {
19-
const now = new Date();
2020
return new GitCommit(
2121
container,
2222
repoPath,

src/plus/integrations/providers/github/sub-providers/commits.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export class CommitsGitSubProvider implements GitCommitsSubProvider {
5151
this.container,
5252
repoPath,
5353
rev,
54+
new Date(),
5455
await this.provider.config.getCurrentUser(repoPath),
5556
);
5657
}

0 commit comments

Comments
 (0)