@@ -11,8 +11,8 @@ import { ConflictModel } from './conflictGuide';
1111import { ConflictResolutionCoordinator } from './conflictResolutionCoordinator' ;
1212import { Conflict , ConflictResolutionModel } from './conflictResolutionModel' ;
1313import { CredentialStore } from './credentials' ;
14- import { CopilotWorkingStatus , GitHubRepository , GraphQLError , GraphQLErrorType , ItemsData , PULL_REQUEST_PAGE_SIZE , PullRequestChangeEvent , PullRequestData , TeamReviewerRefreshKind , ViewerPermission } from './githubRepository' ;
15- import { MergeMethod as GraphQLMergeMethod , MergePullRequestInput , MergePullRequestResponse , PullRequestResponse , PullRequestState } from './graphql' ;
14+ import { CopilotWorkingStatus , GitHubRepository , ItemsData , PULL_REQUEST_PAGE_SIZE , PullRequestChangeEvent , PullRequestData , TeamReviewerRefreshKind , ViewerPermission } from './githubRepository' ;
15+ import { PullRequestResponse , PullRequestState } from './graphql' ;
1616import { IAccount , ILabel , IMilestone , IProject , IPullRequestsPagingOptions , Issue , ITeam , MergeMethod , PRType , PullRequestMergeability , RepoAccessAndMergeMethods , User } from './interface' ;
1717import { IssueModel } from './issueModel' ;
1818import { PullRequestGitHelper , PullRequestMetadata } from './pullRequestGitHelper' ;
@@ -23,7 +23,6 @@ import {
2323 getOverrideBranch ,
2424 getPRFetchQuery ,
2525 loginComparator ,
26- parseCombinedTimelineEvents ,
2726 parseGraphQLPullRequest ,
2827 teamComparator ,
2928 variableSubstitution ,
@@ -42,7 +41,6 @@ import { GitHubRemote, parseRemote, parseRepositoryRemotes, Remote } from '../co
4241import {
4342 ALLOW_FETCH ,
4443 AUTO_STASH ,
45- DEFAULT_MERGE_METHOD ,
4644 GIT ,
4745 POST_DONE ,
4846 PR_SETTINGS_NAMESPACE ,
@@ -52,7 +50,7 @@ import {
5250 UPSTREAM_REMOTE ,
5351} from '../common/settingKeys' ;
5452import { ITelemetry } from '../common/telemetry' ;
55- import { EventType , TimelineEvent } from '../common/timelineEvent' ;
53+ import { EventType } from '../common/timelineEvent' ;
5654import { Schemes } from '../common/uri' ;
5755import { batchPromiseAll , compareIgnoreCase , formatError , Predicate } from '../common/utils' ;
5856import { PULL_REQUEST_OVERVIEW_VIEW_TYPE } from '../common/webview' ;
@@ -195,9 +193,6 @@ export class FolderRepositoryManager extends Disposable {
195193 private _repositoryPageInformation : Map < string , PageInformation > = new Map < string , PageInformation > ( ) ;
196194 private _addedUpstreamCount : number = 0 ;
197195
198- private _onDidMergePullRequest = this . _register ( new vscode . EventEmitter < void > ( ) ) ;
199- readonly onDidMergePullRequest = this . _onDidMergePullRequest . event ;
200-
201196 private _onDidChangeActivePullRequest = this . _register ( new vscode . EventEmitter < { new : PullRequestModel | undefined , old : PullRequestModel | undefined } > ( ) ) ;
202197 readonly onDidChangeActivePullRequest : vscode . Event < { new : PullRequestModel | undefined , old : PullRequestModel | undefined } > = this . _onDidChangeActivePullRequest . event ;
203198 private _onDidChangeActiveIssue = this . _register ( new vscode . EventEmitter < void > ( ) ) ;
@@ -1681,101 +1676,6 @@ export class FolderRepositoryManager extends Disposable {
16811676 return this . _credentialStore . getCurrentUser ( githubRepository . remote . authProviderId ) ;
16821677 }
16831678
1684- async mergePullRequest (
1685- pullRequest : PullRequestModel ,
1686- title ?: string ,
1687- description ?: string ,
1688- method ?: 'merge' | 'squash' | 'rebase' ,
1689- email ?: string ,
1690- ) : Promise < { merged : boolean , message : string , timeline ?: TimelineEvent [ ] } > {
1691- Logger . debug ( `Merging PR: ${ pullRequest . number } method: ${ method } for user: "${ email } " - enter` , this . id ) ;
1692- const { mutate, schema } = await pullRequest . githubRepository . ensure ( ) ;
1693-
1694- const activePRSHA = this . activePullRequest && this . activePullRequest . head && this . activePullRequest . head . sha ;
1695- const workingDirectorySHA = this . repository . state . HEAD && this . repository . state . HEAD . commit ;
1696- const mergingPRSHA = pullRequest . head && pullRequest . head . sha ;
1697- const workingDirectoryIsDirty = this . repository . state . workingTreeChanges . length > 0 ;
1698- let expectedHeadOid : string | undefined = pullRequest . head ?. sha ;
1699-
1700- if ( activePRSHA === mergingPRSHA ) {
1701- // We're on the branch of the pr being merged.
1702- expectedHeadOid = workingDirectorySHA ;
1703- if ( workingDirectorySHA !== mergingPRSHA ) {
1704- // We are looking at different commit than what will be merged
1705- const { ahead } = this . repository . state . HEAD ! ;
1706- const pluralMessage = vscode . l10n . t ( 'You have {0} unpushed commits on this pull request branch.\n\nWould you like to proceed anyway?' , ahead ?? 'unknown' ) ;
1707- const singularMessage = vscode . l10n . t ( 'You have 1 unpushed commit on this pull request branch.\n\nWould you like to proceed anyway?' ) ;
1708- if ( ahead &&
1709- ( await vscode . window . showWarningMessage (
1710- ahead > 1 ? pluralMessage : singularMessage ,
1711- { modal : true } ,
1712- vscode . l10n . t ( 'Yes' ) ,
1713- ) ) === undefined ) {
1714-
1715- return {
1716- merged : false ,
1717- message : vscode . l10n . t ( 'unpushed changes' ) ,
1718- } ;
1719- }
1720- }
1721-
1722- if ( workingDirectoryIsDirty ) {
1723- // We have made changes to the PR that are not committed
1724- if (
1725- ( await vscode . window . showWarningMessage (
1726- vscode . l10n . t ( 'You have uncommitted changes on this pull request branch.\n\n Would you like to proceed anyway?' ) ,
1727- { modal : true } ,
1728- vscode . l10n . t ( 'Yes' ) ,
1729- ) ) === undefined
1730- ) {
1731- return {
1732- merged : false ,
1733- message : vscode . l10n . t ( 'uncommitted changes' ) ,
1734- } ;
1735- }
1736- }
1737- }
1738- const input : MergePullRequestInput = {
1739- pullRequestId : pullRequest . graphNodeId ,
1740- commitHeadline : title ,
1741- commitBody : description ,
1742- expectedHeadOid,
1743- authorEmail : email ,
1744- mergeMethod :
1745- ( method ?. toUpperCase ( ) ??
1746- vscode . workspace . getConfiguration ( PR_SETTINGS_NAMESPACE ) . get < 'merge' | 'squash' | 'rebase' > ( DEFAULT_MERGE_METHOD , 'merge' ) ?. toUpperCase ( ) ) as GraphQLMergeMethod ,
1747- } ;
1748-
1749- return mutate < MergePullRequestResponse > ( {
1750- mutation : schema . MergePullRequest ,
1751- variables : {
1752- input
1753- }
1754- } )
1755- . then ( async ( result ) => {
1756- Logger . debug ( `Merging PR: ${ pullRequest . number } } - done` , this . id ) ;
1757-
1758- /* __GDPR__
1759- "pr.merge.success" : {}
1760- */
1761- this . telemetry . sendTelemetryEvent ( 'pr.merge.success' ) ;
1762- this . _onDidMergePullRequest . fire ( ) ;
1763- return { merged : true , message : '' , timeline : await parseCombinedTimelineEvents ( result . data ?. mergePullRequest . pullRequest . timelineItems . nodes ?? [ ] , await pullRequest . getCopilotTimelineEvents ( pullRequest ) , pullRequest . githubRepository ) } ;
1764- } )
1765- . catch ( e => {
1766- /* __GDPR__
1767- "pr.merge.failure" : {}
1768- */
1769- this . telemetry . sendTelemetryErrorEvent ( 'pr.merge.failure' ) ;
1770- const graphQLErrors = e . graphQLErrors as GraphQLError [ ] | undefined ;
1771- if ( graphQLErrors ?. length && graphQLErrors . find ( error => error . type === GraphQLErrorType . Unprocessable && error . message ?. includes ( 'Head branch was modified' ) ) ) {
1772- return { merged : false , message : vscode . l10n . t ( 'Head branch was modified. Pull, review, then try again.' ) } ;
1773- } else {
1774- throw e ;
1775- }
1776- } ) ;
1777- }
1778-
17791679 async deleteBranch ( pullRequest : PullRequestModel ) {
17801680 await pullRequest . githubRepository . deleteBranch ( pullRequest ) ;
17811681 }
0 commit comments