Skip to content

Commit b189480

Browse files
committed
remove unused idea of cherry picking
1 parent ba8713a commit b189480

File tree

12 files changed

+25
-684
lines changed

12 files changed

+25
-684
lines changed

app/src/lib/components/BranchCard.svelte

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@
1717
import Resizer from '$lib/components/Resizer.svelte';
1818
import { projectAiGenAutoBranchNamingEnabled } from '$lib/config/config';
1919
import { projectAiGenEnabled } from '$lib/config/config';
20-
import {
21-
DraggableCommit,
22-
DraggableFile,
23-
DraggableHunk,
24-
DraggableRemoteCommit
25-
} from '$lib/dragging/draggables';
20+
import { DraggableCommit, DraggableFile, DraggableHunk } from '$lib/dragging/draggables';
2621
import { dropzone } from '$lib/dragging/dropzone';
2722
import { showError } from '$lib/notifications/toasts';
2823
import { persisted } from '$lib/persisted/persisted';
@@ -114,14 +109,6 @@
114109
branchController.moveCommit(branch.id, data.commit.id);
115110
}
116111
117-
function acceptCherrypick(data: any) {
118-
return data instanceof DraggableRemoteCommit && data.branchId === branch.id;
119-
}
120-
121-
function onCherrypicked(data: DraggableRemoteCommit) {
122-
branchController.cherryPick(branch.id, data.remoteCommit.id);
123-
}
124-
125112
function acceptBranchDrop(data: any) {
126113
if (data instanceof DraggableHunk && data.branchId !== branch.id) {
127114
return !data.hunk.locked;
@@ -203,8 +190,6 @@
203190
/>
204191
<PullRequestCard />
205192
<!-- DROPZONES -->
206-
<DropzoneOverlay class="cherrypick-dz-marker" label="Apply here" />
207-
<DropzoneOverlay class="cherrypick-dz-marker" label="Apply here" />
208193
<DropzoneOverlay class="lane-dz-marker" label="Move here" />
209194

210195
<div class="card">
@@ -217,13 +202,6 @@
217202
onDrop: onCommitDrop,
218203
disabled: isUnapplied
219204
}}
220-
use:dropzone={{
221-
hover: 'cherrypick-dz-hover',
222-
active: 'cherrypick-dz-active',
223-
accepts: acceptCherrypick,
224-
onDrop: onCherrypicked,
225-
disabled: isUnapplied
226-
}}
227205
use:dropzone={{
228206
hover: 'lane-dz-hover',
229207
active: 'lane-dz-active',
@@ -232,7 +210,6 @@
232210
disabled: isUnapplied
233211
}}
234212
>
235-
<DropzoneOverlay class="cherrypick-dz-marker" label="Apply here" />
236213
<DropzoneOverlay class="lane-dz-marker" label="Move here" />
237214
<DropzoneOverlay class="move-commit-dz-marker" label="Move here" />
238215

app/src/lib/dragging/draggables.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AnyCommit, AnyFile, Commit, Hunk, RemoteCommit } from '../vbranches/types';
1+
import type { AnyCommit, AnyFile, Commit, Hunk } from '../vbranches/types';
22

33
export function nonDraggable() {
44
return {
@@ -36,11 +36,4 @@ export class DraggableCommit {
3636
) {}
3737
}
3838

39-
export class DraggableRemoteCommit {
40-
constructor(
41-
public readonly branchId: string,
42-
public readonly remoteCommit: RemoteCommit
43-
) {}
44-
}
45-
4639
export type Draggable = DraggableFile | DraggableHunk | DraggableCommit;

app/src/lib/vbranches/branchController.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -280,25 +280,6 @@ You can find them in the 'Branches' sidebar in order to resolve conflicts.`;
280280
}
281281
}
282282

283-
async cherryPick(branchId: string, targetCommitOid: string) {
284-
try {
285-
await invoke<void>('cherry_pick_onto_virtual_branch', {
286-
projectId: this.projectId,
287-
branchId,
288-
targetCommitOid
289-
});
290-
} catch (err: any) {
291-
// TODO: Probably we wanna have error code checking in a more generic way
292-
if (err.code === 'errors.commit.signing_failed') {
293-
showSignError(err);
294-
} else {
295-
showError('Failed to cherry-pick commit', err);
296-
}
297-
} finally {
298-
this.targetBranchService.reload();
299-
}
300-
}
301-
302283
async markResolved(path: string) {
303284
try {
304285
await invoke<void>('mark_resolved', { projectId: this.projectId, path });

crates/gitbutler-core/src/project_repository/repository.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ impl Repository {
227227
Ok(())
228228
}
229229
Err(err) => match err.code() {
230-
git2::ErrorCode::NotFound => Ok(()),
230+
git2::ErrorCode::NotFound => {
231+
println!("not found!!!!");
232+
Ok(())
233+
}
231234
_ => Err(err),
232235
},
233236
}

crates/gitbutler-core/src/virtual_branches/base.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ pub fn update_base_branch<'repo>(
366366
.map(|(branch, _)| branch)
367367
.map(
368368
|mut branch: branch::Branch| -> Result<Option<branch::Branch>> {
369+
println!("1");
369370
let branch_tree = repo.find_tree(branch.tree)?;
370371

371372
let branch_head_commit = repo.find_commit(branch.head).context(format!(
@@ -416,12 +417,14 @@ pub fn update_base_branch<'repo>(
416417
.context(format!("failed to merge trees for branch {}", branch.id))?;
417418

418419
if branch_tree_merge_index.has_conflicts() {
420+
println!("CONFLICTS DETECTED");
419421
// branch tree conflicts with new target, unapply branch for now. we'll handle it later, when user applies it back.
420422
let unapplied_real_branch = convert_to_real_branch(
421423
project_repository,
422424
branch.id,
423425
Default::default(),
424-
)?;
426+
)
427+
.expect("Failed to convert to real branch");
425428
unapplied_branch_names.push(unapplied_real_branch);
426429

427430
return Ok(Some(branch));
@@ -450,13 +453,15 @@ pub fn update_base_branch<'repo>(
450453
))?;
451454

452455
if branch_head_merge_index.has_conflicts() {
456+
println!("\n\nConflicts detected!!!\n");
453457
// branch commits conflict with new target, make sure the branch is
454458
// unapplied. conflicts witll be dealt with when applying it back.
455459
let unapplied_real_branch = convert_to_real_branch(
456460
project_repository,
457461
branch.id,
458462
Default::default(),
459-
)?;
463+
)
464+
.expect("2 failed to convert to real branch");
460465
unapplied_branch_names.push(unapplied_real_branch);
461466

462467
return Ok(Some(branch));

crates/gitbutler-core/src/virtual_branches/controller.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -321,18 +321,6 @@ impl Controller {
321321
.await
322322
}
323323

324-
pub async fn cherry_pick(
325-
&self,
326-
project_id: ProjectId,
327-
branch_id: BranchId,
328-
commit_oid: git2::Oid,
329-
) -> Result<Option<git2::Oid>> {
330-
self.inner(project_id)
331-
.await
332-
.cherry_pick(project_id, branch_id, commit_oid)
333-
.await
334-
}
335-
336324
pub async fn list_remote_branches(
337325
&self,
338326
project_id: ProjectId,
@@ -818,22 +806,6 @@ impl ControllerInner {
818806
.await?
819807
}
820808

821-
pub async fn cherry_pick(
822-
&self,
823-
project_id: ProjectId,
824-
branch_id: BranchId,
825-
commit_oid: git2::Oid,
826-
) -> Result<Option<git2::Oid>> {
827-
let _permit = self.semaphore.acquire().await;
828-
829-
self.with_verify_branch(project_id, |project_repository, _| {
830-
let _ = project_repository
831-
.project()
832-
.create_snapshot(SnapshotDetails::new(OperationKind::CherryPick));
833-
super::cherry_pick(project_repository, branch_id, commit_oid).map_err(Into::into)
834-
})
835-
}
836-
837809
pub fn list_remote_branches(&self, project_id: ProjectId) -> Result<Vec<super::RemoteBranch>> {
838810
let project = self.projects.get(project_id)?;
839811
let project_repository = project_repository::Repository::open(&project)?;

0 commit comments

Comments
 (0)