Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lint_pid=''
# Stream a NUL-delimited list directly to xargs -0 so paths with spaces/newlines
# are handled safely (command substitution would strip NUL bytes).
if git diff --cached --name-only --diff-filter=ACMR -- '*.ts' '*.tsx' | grep -q .; then
git diff --cached --name-only --diff-filter=ACMR -z -- '*.ts' '*.tsx' | xargs -0 node ./node_modules/eslint/bin/eslint.js --fix --cache &
git diff --cached --name-only --diff-filter=ACMR -z -- '*.ts' '*.tsx' | xargs -0 node ./node_modules/eslint/bin/eslint.js --fix --cache --no-warn-ignored &
lint_pid=$!
fi

Expand Down
1 change: 1 addition & 0 deletions resources/icons/codicons/layers.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export function onceEvent<T>(event: Event<T>): Event<T> {
};
}

export function isObject(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null;
}

function isWindowsPath(path: string): boolean {
return /^[a-zA-Z]:\\/.test(path);
}
Expand Down
26 changes: 26 additions & 0 deletions src/github/activityBarViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export class PullRequestViewProvider extends WebviewViewBase implements vscode.W
return this.createComment(message);
case 'pr.merge':
return this.mergePullRequest(message);
case 'pr.merge-stack':
return PullRequestReviewCommon.mergeStack(this.getReviewContext(), message);
case 'pr.open-create':
return this.create();
case 'pr.deleteBranch':
Expand Down Expand Up @@ -300,6 +302,9 @@ export class PullRequestViewProvider extends WebviewViewBase implements vscode.W
mergeMethodsAvailability,
defaultMergeMethod,
mergeQueueMethod,
stack: undefined,
stackLoaded: false,
stackLoadError: false,
repositoryDefaultBranch: defaultBranch,
doneCheckoutBranch,
isIssue: false,
Expand All @@ -318,6 +323,27 @@ export class PullRequestViewProvider extends WebviewViewBase implements vscode.W
command: 'pr.initialize',
pullrequest: context,
});
void pullRequest.getStack().then(async stack => {
if (!this._item.equals(pullRequest)) {
return;
}
const stackQueueMethod = stack ? await this._folderRepositoryManager.mergeQueueMethodForBranch(stack.base, pullRequest.remote.owner, pullRequest.remote.repositoryName) : undefined;
if (this._item.equals(pullRequest)) {
Comment on lines +326 to +331
this._postMessage({
command: 'pr.update',
pullrequest: {
stack,
stackLoaded: true,
...(stack ? { mergeQueueMethod: stackQueueMethod } : {}),
} satisfies Partial<PullRequest>,
});
}
}).catch(error => {
Logger.error(`Failed to load active pull request stack: ${formatError(error)}`, PullRequestViewProvider.name);
if (this._item.equals(pullRequest)) {
this._postMessage({ command: 'pr.update', pullrequest: { stackLoadError: true } satisfies Partial<PullRequest> });
}
});

} catch (e) {
vscode.window.showErrorMessage(`Error updating active pull request view: ${formatError(e)}`);
Expand Down
4 changes: 2 additions & 2 deletions src/github/githubRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export class GitHubRepository extends Disposable {
}
}

query = async <T>(query: QueryOptions, ignoreSamlErrors: boolean = false, legacyFallback?: { query: DocumentNode, variables: OperationVariables }): Promise<ApolloQueryResult<T>> => {
query = async <T>(query: QueryOptions, ignoreSamlErrors: boolean = false, legacyFallback?: { query: DocumentNode, variables: OperationVariables }, allowLimitedFallback: boolean = true): Promise<ApolloQueryResult<T>> => {
const gql = this.authMatchesServer && this.hub && this.hub.graphql;
if (!gql) {
const logValue = (query.query.definitions[0] as { name: { value: string } | undefined }).name?.value;
Expand All @@ -367,7 +367,7 @@ export class GitHubRepository extends Disposable {
return this.query(query, ignoreSamlErrors);
}

if (gqlErrors && gqlErrors.length && (gqlErrors.some(error => error.extensions?.code === 'undefinedField')) && !this._areQueriesLimited) {
if (allowLimitedFallback && gqlErrors && gqlErrors.length && (gqlErrors.some(error => error.extensions?.code === 'undefinedField')) && !this._areQueriesLimited) {
// We're running against a GitHub server that doesn't support the query we're trying to run.
// Switch to the limited schema and try again.
this._areQueriesLimited = true;
Expand Down
29 changes: 29 additions & 0 deletions src/github/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { ForkDetails } from './githubRepository';
import { GithubItemStateEnum } from './interface';
import { DiffSide, SubjectType, ViewedState } from '../common/comment';

interface PageInfo {
Expand Down Expand Up @@ -815,6 +816,34 @@ export interface PullRequestResponse {
rateLimit: RateLimit;
}

export interface PullRequestStackResponse {
repository: {
pullRequest: {
stackEntry: { position: number } | null;
stack: {
size: number;
baseRefName: string;
entries: {
nodes: {
position: number;
pullRequest: {
number: number;
title: string;
url: string;
state: GithubItemStateEnum;
isDraft: boolean;
headRefName: string;
mergeable: 'MERGEABLE' | 'CONFLICTING' | 'UNKNOWN';
mergeStateStatus: 'BEHIND' | 'BLOCKED' | 'CLEAN' | 'DIRTY' | 'HAS_HOOKS' | 'UNKNOWN' | 'UNSTABLE';
};
}[];
pageInfo: { hasNextPage: boolean; endCursor: string | null };
};
} | null;
} | null;
} | null;
}

export interface IssueResponse {
repository: {
issue: PullRequest;
Expand Down
16 changes: 16 additions & 0 deletions src/github/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ export enum GithubItemStateEnum {
Closed = 'CLOSED',
}

export interface PullRequestStack {
position: number;
size: number;
base: string;
pullRequests: {
position: number;
number: number;
title: string;
url: string;
head: string;
state: GithubItemStateEnum;
isDraft: boolean;
mergeable: PullRequestMergeability;
}[];
}

export enum PullRequestMergeability {
Mergeable,
NotMergeable,
Expand Down
7 changes: 3 additions & 4 deletions src/github/loggingOctokit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { GitHubRef } from '../common/githubRef';
import Logger from '../common/logger';
import { GitHubRemote } from '../common/remote';
import { ITelemetry } from '../common/telemetry';
import { isObject } from '../common/utils';

interface RestResponse {
headers: {
Expand All @@ -35,15 +36,13 @@ export enum GraphQLErrorType {
export interface GraphQLError {
extensions?: {
code: string;
typeName?: string;
fieldName?: string;
};
type?: GraphQLErrorType;
message?: string;
}

function isObject(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null;
}

/**
* Detects whether an error from a REST (Octokit) or GraphQL (Apollo) call
* indicates that the GitHub authentication token is no longer valid. This
Expand Down
Loading
Loading