Skip to content

Commit 8feddeb

Browse files
committed
rebase & lint fixes
1 parent 1542a55 commit 8feddeb

File tree

5 files changed

+27
-33
lines changed

5 files changed

+27
-33
lines changed

src/env/node/git/git.ts

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,43 +75,42 @@ const textDecoder = new TextDecoder('utf8');
7575
const rootSha = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
7676

7777
export const GitErrors = {
78+
alreadyCheckedOut: /already checked out/i,
79+
alreadyExists: /already exists/i,
80+
ambiguousArgument: /fatal:\s*ambiguous argument ['"].+['"]: unknown revision or path not in the working tree/i,
7881
badRevision: /bad revision '(.*?)'/i,
7982
cantLockRef: /cannot lock ref|unable to update local ref/i,
80-
changesWouldBeOverwritten: /Your local changes to the following files would be overwritten/i,
83+
changesWouldBeOverwritten: /error:\s*Your local changes to the following files would be overwritten/i,
8184
commitChangesFirst: /Please, commit your changes before you can/i,
8285
conflict: /^CONFLICT \([^)]+\): \b/m,
86+
entryNotUpToDate: /error:\s*Entry ['"].+['"] not uptodate\. Cannot merge\./i,
8387
failedToDeleteDirectoryNotEmpty: /failed to delete '(.*?)': Directory not empty/i,
88+
invalidLineCount: /file .+? has only \d+ lines/i,
8489
invalidObjectName: /invalid object name: (.*)\s/i,
8590
invalidObjectNameList: /could not open object name list: (.*)\s/i,
91+
invalidTagName: /invalid tag name/i,
92+
mainWorkingTree: /is a main working tree/i,
8693
noFastForward: /\(non-fast-forward\)/i,
8794
noMergeBase: /no merge base/i,
8895
noRemoteRepositorySpecified: /No remote repository specified\./i,
96+
noUpstream: /^fatal: The current branch .* has no upstream branch/i,
97+
noUserNameConfigured: /Please tell me who you are\./i,
8998
notAValidObjectName: /Not a valid object name/i,
9099
notAWorkingTree: /'(.*?)' is not a working tree/i,
91-
noUserNameConfigured: /Please tell me who you are\./i,
92-
invalidLineCount: /file .+? has only \d+ lines/i,
93-
uncommittedChanges: /contains modified or untracked files/i,
94-
alreadyExists: /already exists/i,
95-
alreadyCheckedOut: /already checked out/i,
96-
mainWorkingTree: /is a main working tree/i,
97-
noUpstream: /^fatal: The current branch .* has no upstream branch/i,
98100
permissionDenied: /Permission.*denied/i,
99101
pushRejected: /^error: failed to push some refs to\b/m,
100102
rebaseMultipleBranches: /cannot rebase onto multiple branches/i,
103+
refLocked: /fatal:\s*cannot lock ref ['"].+['"]: unable to create file/i,
101104
remoteAhead: /rejected because the remote contains work/i,
102105
remoteConnection: /Could not read from remote repository/i,
103-
tagConflict: /! \[rejected\].*\(would clobber existing tag\)/m,
104-
unmergedFiles: /is not possible because you have unmerged files/i,
105-
unstagedChanges: /You have unstaged changes/i,
106+
remoteRejected: /rejected because the remote contains work/i,
106107
tagAlreadyExists: /tag .* already exists/i,
108+
tagConflict: /! \[rejected\].*\(would clobber existing tag\)/m,
107109
tagNotFound: /tag .* not found/i,
108-
invalidTagName: /invalid tag name/i,
109-
remoteRejected: /rejected because the remote contains work/i,
110+
uncommittedChanges: /contains modified or untracked files/i,
110111
unmergedChanges: /error:\s*you need to resolve your current index first/i,
111-
ambiguousArgument: /fatal:\s*ambiguous argument ['"].+['"]: unknown revision or path not in the working tree/i,
112-
entryNotUpToDate: /error:\s*Entry ['"].+['"] not uptodate\. Cannot merge\./i,
113-
changesWouldBeOverwritten: /error:\s*Your local changes to the following files would be overwritten/i,
114-
refLocked: /fatal:\s*cannot lock ref ['"].+['"]: unable to create file/i,
112+
unmergedFiles: /is not possible because you have unmerged files/i,
113+
unstagedChanges: /You have unstaged changes/i,
115114
};
116115

117116
const GitWarnings = {
@@ -180,12 +179,11 @@ const tagErrorAndReason: [RegExp, TagErrorReason][] = [
180179
[GitErrors.remoteRejected, TagErrorReason.RemoteRejected],
181180
];
182181

183-
const resetErrorAndReason = [
184-
[unmergedChanges, ResetErrorReason.UnmergedChanges],
185-
[ambiguousArgument, ResetErrorReason.AmbiguousArgument],
186-
[entryNotUpToDate, ResetErrorReason.EntryNotUpToDate],
187-
[changesWouldBeOverwritten, ResetErrorReason.LocalChangesWouldBeOverwritten],
188-
[refLocked, ResetErrorReason.RefLocked],
182+
const resetErrorAndReason: [RegExp, ResetErrorReason][] = [
183+
[GitErrors.unmergedChanges, ResetErrorReason.UnmergedChanges],
184+
[GitErrors.ambiguousArgument, ResetErrorReason.AmbiguousArgument],
185+
[GitErrors.entryNotUpToDate, ResetErrorReason.EntryNotUpToDate],
186+
[GitErrors.refLocked, ResetErrorReason.RefLocked],
189187
];
190188

191189
export class Git {
@@ -1599,9 +1597,9 @@ export class Git {
15991597
return this.git<string>({ cwd: repoPath }, 'remote', 'get-url', remote);
16001598
}
16011599

1602-
reset(repoPath: string, pathspecs: string[], ...args: string[]) {
1600+
async reset(repoPath: string, pathspecs: string[], ...args: string[]) {
16031601
try {
1604-
return this.git<string>({ cwd: repoPath }, 'reset', '-q', ...args, '--', ...pathspecs);
1602+
await this.git<string>({ cwd: repoPath }, 'reset', '-q', ...args, '--', ...pathspecs);
16051603
} catch (ex) {
16061604
const msg: string = ex?.toString() ?? '';
16071605
for (const [error, reason] of resetErrorAndReason) {

src/env/node/git/localGitProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5975,7 +5975,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
59755975
}
59765976

59775977
@log()
5978-
async reset(repoPath: string, options?: { hard?: boolean; soft?: boolean }, ref?: string): Promise<void> {
5978+
async reset(repoPath: string, ref: string, options?: { hard?: boolean; soft?: boolean }): Promise<void> {
59795979
const flags = [];
59805980
if (options?.hard) {
59815981
flags.push('--hard');

src/git/errors.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,6 @@ export const enum ResetErrorReason {
572572
UnmergedChanges,
573573
AmbiguousArgument,
574574
EntryNotUpToDate,
575-
LocalChangesWouldBeOverwritten,
576575
RefLocked,
577576
Other,
578577
}
@@ -607,9 +606,6 @@ export class ResetError extends Error {
607606
case ResetErrorReason.EntryNotUpToDate:
608607
message = `${message} because the entry is not up to date`;
609608
break;
610-
case ResetErrorReason.LocalChangesWouldBeOverwritten:
611-
message = `${message} because local changes would be overwritten`;
612-
break;
613609
case ResetErrorReason.RefLocked:
614610
message = `${message} because the ref is locked`;
615611
break;

src/git/gitProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export interface GitProviderRepository {
126126
pruneRemote?(repoPath: string, name: string): Promise<void>;
127127
removeRemote?(repoPath: string, name: string): Promise<void>;
128128

129-
reset?(repoPath: string, options?: { hard?: boolean; soft?: boolean }, ref?: string): Promise<void>;
129+
reset?(repoPath: string, ref: string, options?: { hard?: boolean; soft?: boolean }): Promise<void>;
130130

131131
applyUnreachableCommitForPatch?(
132132
repoPath: string,

src/git/gitProviderService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ export class GitProviderService implements Disposable {
13351335
}
13361336

13371337
@log()
1338-
async reset(repoPath: string, flags: string[], ref?: string): Promise<void> {
1338+
async reset(repoPath: string, flags: string[], ref: string): Promise<void> {
13391339
const { provider, path } = this.getProvider(repoPath);
13401340
if (provider.reset == null) throw new ProviderNotSupportedError(provider.descriptor.name);
13411341

@@ -1353,7 +1353,7 @@ export class GitProviderService implements Disposable {
13531353
}
13541354
}
13551355

1356-
return provider.reset(path, options, ref);
1356+
return provider.reset(path, ref, options);
13571357
}
13581358

13591359
@log()

0 commit comments

Comments
 (0)