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 8, 2024
1 parent 964d3c3 commit ead29af
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4642,23 +4642,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 @@ -171,13 +171,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],
];

const tagErrorAndReason: [RegExp, TagErrorReason][] = [
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 @@ -1256,25 +1256,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 @@ -1309,7 +1309,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 @@ -1319,8 +1319,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
5 changes: 2 additions & 3 deletions src/git/models/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ import { configuration } from '../../system/vscode/configuration';
import type { GitProviderDescriptor, GitProviderRepository } from '../gitProvider';
import type { GitProviderService } from '../gitProviderService';
import type { GitBranch } from './branch';
import type { GitBranchReference, GitReference, GitTagReference } from './reference';
import { getNameWithoutRemote, isBranchReference } from './reference';
import { getBranchNameWithoutRemote, getRemoteNameFromBranchName } from './branch';
import type { GitBranchReference, GitReference } from './reference';
import { isBranchReference } from './reference';
import type { GitRemote } from './remote';
import type { GitWorktree } from './worktree';

Expand Down

0 comments on commit ead29af

Please sign in to comment.