Skip to content

Commit

Permalink
Fixes getting diff for WIP changes when creating Cloud Patches
Browse files Browse the repository at this point in the history
  • Loading branch information
axosoft-ramint committed Nov 10, 2023
1 parent 2818e6e commit 71410e4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/plus/drafts/draftsService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Disposable } from 'vscode';
import type { Container } from '../../container';
import { uncommitted, uncommittedStaged } from '../../git/models/constants';
import { isSha, isUncommitted } from '../../git/models/reference';
import { isRepository } from '../../git/models/repository';
import type { GitUser } from '../../git/models/user';
Expand Down Expand Up @@ -212,12 +213,17 @@ export class DraftService implements Disposable {
private async getCreateDraftPatchRequestFromChange(
change: CreateDraftChange,
): Promise<CreateDraftPatchRequestFromChange> {
const isWIP = change.revision.sha === uncommitted || change.revision.sha === uncommittedStaged;
const [branchNamesResult, diffResult, firstShaResult, remoteResult, userResult] = await Promise.allSettled([
isUncommitted(change.revision.sha)
? this.container.git.getBranch(change.repository.uri).then(b => (b != null ? [b.name] : undefined))
: this.container.git.getCommitBranches(change.repository.uri, change.revision.sha),
change.contents == null
? this.container.git.getDiff(change.repository.path, change.revision.baseSha, change.revision.sha)
? this.container.git.getDiff(
change.repository.path,
isWIP ? change.revision.sha : change.revision.baseSha,
isWIP ? change.revision.baseSha : change.revision.sha,
)
: undefined,
this.container.git.getFirstCommitSha(change.repository.uri),
this.container.git.getBestRemoteWithProvider(change.repository.uri),
Expand Down

0 comments on commit 71410e4

Please sign in to comment.