1
- import { dropDataToDiffSpec } from '$lib/commits/utils' ;
1
+ import { changesToDiffSpec } from '$lib/commits/utils' ;
2
2
import {
3
3
ChangeDropData ,
4
4
FileDropData ,
@@ -48,15 +48,15 @@ export class StartCommitDzHandler implements DropzoneHandler {
48
48
( data instanceof HunkDropDataV3 && data . uncommitted )
49
49
) ;
50
50
}
51
- ondrop ( data : ChangeDropData | HunkDropDataV3 ) : void {
51
+ async ondrop ( data : ChangeDropData | HunkDropDataV3 ) : Promise < void > {
52
52
const { projectId, stackId, branchName, uiState, uncommittedService } = this . args ;
53
53
54
54
const projectState = uiState . project ( projectId ) ;
55
55
const stackState = stackId ? uiState . stack ( stackId ) : undefined ;
56
56
57
57
uncommittedService . uncheckAll ( null ) ;
58
58
if ( data instanceof ChangeDropData ) {
59
- for ( const change of data . changes ) {
59
+ for ( const change of await data . treeChanges ( ) ) {
60
60
uncommittedService . checkFile ( null , change . path ) ;
61
61
}
62
62
} else if ( data instanceof HunkDropDataV3 ) {
@@ -126,14 +126,15 @@ export class AmendCommitWithChangeDzHandler implements DropzoneHandler {
126
126
case 'commit' : {
127
127
const sourceStackId = data . stackId ;
128
128
const sourceCommitId = data . selectionId . commitId ;
129
+ const changes = changesToDiffSpec ( await data . treeChanges ( ) ) ;
129
130
if ( sourceStackId && sourceCommitId ) {
130
131
const { replacedCommits } = await this . stackService . moveChangesBetweenCommits ( {
131
132
projectId : this . projectId ,
132
133
destinationStackId : this . stackId ,
133
134
destinationCommitId : this . commit . id ,
134
135
sourceStackId,
135
136
sourceCommitId,
136
- changes : dropDataToDiffSpec ( data )
137
+ changes
137
138
} ) ;
138
139
139
140
// Update the project state to point to the new commit if needed.
@@ -147,16 +148,18 @@ export class AmendCommitWithChangeDzHandler implements DropzoneHandler {
147
148
case 'branch' :
148
149
console . warn ( 'Moving a branch into a commit is an invalid operation' ) ;
149
150
break ;
150
- case 'worktree' :
151
- this . onresult (
151
+ case 'worktree' : {
152
+ const diffSpec = changesToDiffSpec ( await data . treeChanges ( ) ) ;
153
+ return this . onresult (
152
154
await this . trigger ( {
153
155
projectId : this . projectId ,
154
156
stackId : this . stackId ,
155
157
branchName : this . branchName ,
156
158
commitId : this . commit . id ,
157
- worktreeChanges : dropDataToDiffSpec ( data )
159
+ worktreeChanges : diffSpec
158
160
} )
159
161
) ;
162
+ }
160
163
}
161
164
}
162
165
}
@@ -191,11 +194,12 @@ export class UncommitDzHandler implements DropzoneHandler {
191
194
const stackId = data . stackId ;
192
195
const commitId = data . selectionId . commitId ;
193
196
if ( stackId && commitId ) {
197
+ const changes = changesToDiffSpec ( await data . treeChanges ( ) ) ;
194
198
const { replacedCommits } = await this . stackService . uncommitChanges ( {
195
199
projectId : this . projectId ,
196
200
stackId,
197
201
commitId,
198
- changes : dropDataToDiffSpec ( data )
202
+ changes
199
203
} ) ;
200
204
201
205
// Update the project state to point to the new commit if needed.
0 commit comments