mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-26 12:24:26 +03:00
reflect squashing rules in ui
This commit is contained in:
parent
a98ea8ccc3
commit
08e41f46d1
@ -79,6 +79,10 @@ export class Commit {
|
||||
files!: File[];
|
||||
parentIds!: string[];
|
||||
branchId!: string;
|
||||
|
||||
isParentOf(possibleChild: Commit) {
|
||||
return possibleChild.parentIds.includes(this.id);
|
||||
}
|
||||
}
|
||||
|
||||
export class RemoteCommit {
|
||||
|
@ -59,22 +59,28 @@
|
||||
|
||||
function acceptSquash(commit: Commit) {
|
||||
return (data: any) => {
|
||||
return (
|
||||
isDraggableCommit(data) &&
|
||||
data.branchId == branch.id &&
|
||||
(commit.parentIds.includes(data.commit.id) || data.commit.parentIds.includes(commit.id))
|
||||
);
|
||||
if (!isDraggableCommit(data)) return false;
|
||||
if (data.branchId != branch.id) return false;
|
||||
|
||||
if (data.commit.isParentOf(commit)) {
|
||||
if (data.commit.isIntegrated) return false;
|
||||
if (data.commit.isRemote && !project.ok_with_force_push) return false;
|
||||
return true;
|
||||
} else if (commit.isParentOf(data.commit)) {
|
||||
if (commit.isIntegrated) return false;
|
||||
if (commit.isRemote && !project.ok_with_force_push) return false;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function onSquash(commit: Commit) {
|
||||
function isParentOf(commit: Commit, other: Commit) {
|
||||
return commit.parentIds.includes(other.id);
|
||||
}
|
||||
return (data: DraggableCommit) => {
|
||||
if (isParentOf(commit, data.commit)) {
|
||||
if (data.commit.isParentOf(commit)) {
|
||||
branchController.squashBranchCommit(data.branchId, commit.id);
|
||||
} else if (isParentOf(data.commit, commit)) {
|
||||
} else if (commit.isParentOf(data.commit)) {
|
||||
branchController.squashBranchCommit(data.branchId, data.commit.id);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user