Skip to content

Commit 3adc472

Browse files
committed
rebase & lint fixes
1 parent 0c17c53 commit 3adc472

File tree

4 files changed

+23
-24
lines changed

4 files changed

+23
-24
lines changed

src/env/node/git/git.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,39 +74,38 @@ const textDecoder = new TextDecoder('utf8');
7474
const rootSha = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
7575

7676
export const GitErrors = {
77+
alreadyCheckedOut: /already checked out/i,
78+
alreadyExists: /already exists/i,
79+
ambiguousArgument: /fatal:\s*ambiguous argument ['"].+['"]: unknown revision or path not in the working tree/i,
7780
badRevision: /bad revision '(.*?)'/i,
7881
cantLockRef: /cannot lock ref|unable to update local ref/i,
7982
changesWouldBeOverwritten: /Your local changes to the following files would be overwritten/i,
8083
commitChangesFirst: /Please, commit your changes before you can/i,
8184
conflict: /^CONFLICT \([^)]+\): \b/m,
85+
entryNotUpToDate: /error:\s*Entry ['"].+['"] not uptodate\. Cannot merge\./i,
8286
failedToDeleteDirectoryNotEmpty: /failed to delete '(.*?)': Directory not empty/i,
87+
invalidLineCount: /file .+? has only \d+ lines/i,
8388
invalidObjectName: /invalid object name: (.*)\s/i,
8489
invalidObjectNameList: /could not open object name list: (.*)\s/i,
90+
mainWorkingTree: /is a main working tree/i,
8591
noFastForward: /\(non-fast-forward\)/i,
8692
noMergeBase: /no merge base/i,
8793
noRemoteRepositorySpecified: /No remote repository specified\./i,
94+
noUpstream: /^fatal: The current branch .* has no upstream branch/i,
95+
noUserNameConfigured: /Please tell me who you are\./i,
8896
notAValidObjectName: /Not a valid object name/i,
8997
notAWorkingTree: /'(.*?)' is not a working tree/i,
90-
noUserNameConfigured: /Please tell me who you are\./i,
91-
invalidLineCount: /file .+? has only \d+ lines/i,
92-
uncommittedChanges: /contains modified or untracked files/i,
93-
alreadyExists: /already exists/i,
94-
alreadyCheckedOut: /already checked out/i,
95-
mainWorkingTree: /is a main working tree/i,
96-
noUpstream: /^fatal: The current branch .* has no upstream branch/i,
9798
permissionDenied: /Permission.*denied/i,
9899
pushRejected: /^error: failed to push some refs to\b/m,
99100
rebaseMultipleBranches: /cannot rebase onto multiple branches/i,
101+
refLocked: /fatal:\s*cannot lock ref ['"].+['"]: unable to create file/i,
100102
remoteAhead: /rejected because the remote contains work/i,
101103
remoteConnection: /Could not read from remote repository/i,
102104
tagConflict: /! \[rejected\].*\(would clobber existing tag\)/m,
105+
uncommittedChanges: /contains modified or untracked files/i,
106+
unmergedChanges: /error:\s*you need to resolve your current index first/i,
103107
unmergedFiles: /is not possible because you have unmerged files/i,
104108
unstagedChanges: /You have unstaged changes/i,
105-
unmergedChanges: /error:\s*you need to resolve your current index first/i,
106-
ambiguousArgument: /fatal:\s*ambiguous argument ['"].+['"]: unknown revision or path not in the working tree/i,
107-
entryNotUpToDate: /error:\s*Entry ['"].+['"] not uptodate\. Cannot merge\./i,
108-
changesWouldBeOverwritten: /error:\s*Your local changes to the following files would be overwritten/i,
109-
refLocked: /fatal:\s*cannot lock ref ['"].+['"]: unable to create file/i,
110109
};
111110

112111
const GitWarnings = {
@@ -167,12 +166,12 @@ function getStdinUniqueKey(): number {
167166
type ExitCodeOnlyGitCommandOptions = GitCommandOptions & { exitCodeOnly: true };
168167
export type PushForceOptions = { withLease: true; ifIncludes?: boolean } | { withLease: false; ifIncludes?: never };
169168

170-
const resetErrorAndReason = [
171-
[unmergedChanges, ResetErrorReason.UnmergedChanges],
172-
[ambiguousArgument, ResetErrorReason.AmbiguousArgument],
173-
[entryNotUpToDate, ResetErrorReason.EntryNotUpToDate],
174-
[changesWouldBeOverwritten, ResetErrorReason.LocalChangesWouldBeOverwritten],
175-
[refLocked, ResetErrorReason.RefLocked],
169+
const resetErrorAndReason: [RegExp, ResetErrorReason][] = [
170+
[GitErrors.unmergedChanges, ResetErrorReason.UnmergedChanges],
171+
[GitErrors.ambiguousArgument, ResetErrorReason.AmbiguousArgument],
172+
[GitErrors.entryNotUpToDate, ResetErrorReason.EntryNotUpToDate],
173+
[GitErrors.changesWouldBeOverwritten, ResetErrorReason.LocalChangesWouldBeOverwritten],
174+
[GitErrors.refLocked, ResetErrorReason.RefLocked],
176175
];
177176

178177
export class Git {
@@ -1586,9 +1585,9 @@ export class Git {
15861585
return this.git<string>({ cwd: repoPath }, 'remote', 'get-url', remote);
15871586
}
15881587

1589-
reset(repoPath: string, pathspecs: string[], ...args: string[]) {
1588+
async reset(repoPath: string, pathspecs: string[], ...args: string[]) {
15901589
try {
1591-
return this.git<string>({ cwd: repoPath }, 'reset', '-q', ...args, '--', ...pathspecs);
1590+
await this.git<string>({ cwd: repoPath }, 'reset', '-q', ...args, '--', ...pathspecs);
15921591
} catch (ex) {
15931592
const msg: string = ex?.toString() ?? '';
15941593
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
@@ -5789,7 +5789,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
57895789
}
57905790

57915791
@log()
5792-
async reset(repoPath: string, options?: { hard?: boolean; soft?: boolean }, ref?: string): Promise<void> {
5792+
async reset(repoPath: string, ref: string, options?: { hard?: boolean; soft?: boolean }): Promise<void> {
57935793
const flags = [];
57945794
if (options?.hard) {
57955795
flags.push('--hard');

src/git/gitProvider.ts

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

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

130130
applyUnreachableCommitForPatch?(
131131
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)