Skip to content

Commit

Permalink
rebase, lint & code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiolms committed Nov 7, 2024
1 parent c739e18 commit 4f145da
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4593,23 +4593,22 @@
"gitlens.advanced.messages": {
"type": "object",
"default": {
"suppressBlameInvalidIgnoreRevsFileBadRevisionWarning": false,
"suppressBlameInvalidIgnoreRevsFileWarning": false,
"suppressCommitHasNoPreviousCommitWarning": false,
"suppressCommitNotFoundWarning": false,
"suppressCreatePullRequestPrompt": false,
"suppressDebugLoggingWarning": false,
"suppressFileNotUnderSourceControlWarning": false,
"suppressGitBranchNotFullyMergedWarning": false,
"suppressGitDisabledWarning": false,
"suppressGitMissingWarning": false,
"suppressGitVersionWarning": false,
"suppressLineUncommittedWarning": false,
"suppressNoRepositoryWarning": false,
"suppressRebaseSwitchToTextWarning": false,
"suppressIntegrationDisconnectedTooManyFailedRequestsWarning": false,
"suppressIntegrationRequestFailed500Warning": false,
"suppressIntegrationRequestTimedOutWarning": false,
"suppressLineUncommittedWarning": false,
"suppressNoRepositoryWarning": false,
"suppressRebaseSwitchToTextWarning": false
"suppressBlameInvalidIgnoreRevsFileWarning": false,
"suppressBlameInvalidIgnoreRevsFileBadRevisionWarning": false
},
"properties": {
"suppressCommitHasNoPreviousCommitWarning": {
Expand Down
4 changes: 1 addition & 3 deletions src/env/node/git/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,11 @@ function getStdinUniqueKey(): number {
type ExitCodeOnlyGitCommandOptions = GitCommandOptions & { exitCodeOnly: true };
export type PushForceOptions = { withLease: true; ifIncludes?: boolean } | { withLease: false; ifIncludes?: never };

const branchErrorAndReason = [
const branchErrorAndReason: [RegExp, BranchErrorReason][] = [
[GitErrors.noRemoteReference, BranchErrorReason.NoRemoteReference],
[GitErrors.invalidBranchName, BranchErrorReason.InvalidBranchName],
[GitErrors.branchAlreadyExists, BranchErrorReason.BranchAlreadyExists],
[GitErrors.branchNotFullyMerged, BranchErrorReason.BranchNotFullyMerged],
[GitErrors.branchNotYetBorn, BranchErrorReason.BranchNotYetBorn],
[GitErrors.branchFastForwardRejected, BranchErrorReason.BranchFastForwardRejected],
];

export class Git {
Expand Down
18 changes: 9 additions & 9 deletions src/env/node/git/localGitProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1255,25 +1255,25 @@ export class LocalGitProvider implements GitProvider, Disposable {
}

@log()
createBranch(repoPath: string, name: string, ref: string): Promise<void> {
async createBranch(repoPath: string, name: string, ref: string): Promise<void> {
try {
return void this.git.branch(repoPath, name, ref);
await this.git.branch(repoPath, name, ref);
} catch (ex) {
if (ex instanceof BranchError) {
throw ex.WithBranch(branch.name);
throw ex.WithBranch(name);
}

throw ex;
}
}

@log()
renameBranch(repoPath: string, oldName: string, newName: string): Promise<void> {
async renameBranch(repoPath: string, oldName: string, newName: string): Promise<void> {
try {
return void this.git.branch(repoPath, '-m', oldName, newName);
await this.git.branch(repoPath, '-m', oldName, newName);
} catch (ex) {
if (ex instanceof BranchError) {
throw ex.WithBranch(branch.name);
throw ex.WithBranch(oldName);
}

throw ex;
Expand Down Expand Up @@ -1308,7 +1308,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
}

const remote = getRemoteNameFromBranchName(branch.upstream.name);
remoteCommit = await this.git.rev_list(repoPath, `refs/remotes/${remote}/${branch.ref}`, {
const remoteCommit = await this.git.rev_list(repoPath, `refs/remotes/${remote}/${branch.ref}`, {
maxResults: 1,
});

Expand All @@ -1318,8 +1318,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
await this.git.branch(repoPath, ...args, branch.ref);
} catch (ex) {
// If it fails, restore the remote branch
await this.git.update_ref(repoPath, `refs/remotes/${remote}/${branch.ref}`, commit);
await this.git.branch__set_upstream(repoPath, branch, remote, branch);
await this.git.update_ref(repoPath, `refs/remotes/${remote}/${branch.ref}`, remoteCommit?.[0] ?? '');
await this.git.branch__set_upstream(repoPath, branch.name, remote, branch.ref);
throw ex;
}

Expand Down

0 comments on commit 4f145da

Please sign in to comment.