mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-16 21:12:00 +03:00
use per-branch flag to check if rebasing is allowed
This commit is contained in:
parent
03214dcaa1
commit
d4267b81d5
@ -255,7 +255,7 @@ pub fn set_base_branch(
|
|||||||
ownership,
|
ownership,
|
||||||
order: 0,
|
order: 0,
|
||||||
selected_for_changes: None,
|
selected_for_changes: None,
|
||||||
allow_rebasing: true,
|
allow_rebasing: project_repository.project().ok_with_force_push.into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
vb_state.set_branch(branch)?;
|
vb_state.set_branch(branch)?;
|
||||||
@ -472,7 +472,7 @@ pub fn update_base_branch(
|
|||||||
branch.id
|
branch.id
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
let ok_with_force_push = project_repository.project().ok_with_force_push;
|
let ok_with_force_push = branch.allow_rebasing;
|
||||||
|
|
||||||
let result_merge =
|
let result_merge =
|
||||||
|mut branch: branch::Branch| -> Result<Option<branch::Branch>> {
|
|mut branch: branch::Branch| -> Result<Option<branch::Branch>> {
|
||||||
|
@ -329,7 +329,7 @@ pub fn apply_branch(
|
|||||||
.find_tree(merged_branch_tree_oid)
|
.find_tree(merged_branch_tree_oid)
|
||||||
.context("failed to find tree")?;
|
.context("failed to find tree")?;
|
||||||
|
|
||||||
let ok_with_force_push = project_repository.project().ok_with_force_push;
|
let ok_with_force_push = branch.allow_rebasing;
|
||||||
if branch.upstream.is_some() && !ok_with_force_push {
|
if branch.upstream.is_some() && !ok_with_force_push {
|
||||||
// branch was pushed to upstream, and user doesn't like force pushing.
|
// branch was pushed to upstream, and user doesn't like force pushing.
|
||||||
// create a merge commit to avoid the need of force pushing then.
|
// create a merge commit to avoid the need of force pushing then.
|
||||||
@ -1059,7 +1059,7 @@ pub fn create_virtual_branch(
|
|||||||
ownership: BranchOwnershipClaims::default(),
|
ownership: BranchOwnershipClaims::default(),
|
||||||
order,
|
order,
|
||||||
selected_for_changes,
|
selected_for_changes,
|
||||||
allow_rebasing: true,
|
allow_rebasing: project_repository.project().ok_with_force_push.into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(ownership) = &create.ownership {
|
if let Some(ownership) = &create.ownership {
|
||||||
@ -1159,7 +1159,7 @@ pub fn integrate_upstream_commits(
|
|||||||
|
|
||||||
// Booleans needed for a decision on how integrate upstream commits.
|
// Booleans needed for a decision on how integrate upstream commits.
|
||||||
// let is_same_base = default_target.sha == merge_base;
|
// let is_same_base = default_target.sha == merge_base;
|
||||||
let can_use_force = *project.ok_with_force_push;
|
let can_use_force = branch.allow_rebasing;
|
||||||
let has_rebased_commits = !rebased_commits.is_empty();
|
let has_rebased_commits = !rebased_commits.is_empty();
|
||||||
|
|
||||||
// We can't proceed if we rebased local commits but no permission to force push. In this
|
// We can't proceed if we rebased local commits but no permission to force push. In this
|
||||||
@ -1368,6 +1368,10 @@ pub fn update_branch(
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(allow_rebasing) = branch_update.allow_rebasing {
|
||||||
|
branch.allow_rebasing = allow_rebasing;
|
||||||
|
};
|
||||||
|
|
||||||
vb_state.set_branch(branch.clone())?;
|
vb_state.set_branch(branch.clone())?;
|
||||||
Ok(branch)
|
Ok(branch)
|
||||||
}
|
}
|
||||||
@ -2890,7 +2894,7 @@ pub fn amend(
|
|||||||
.find(|(b, _)| b.id == branch_id)
|
.find(|(b, _)| b.id == branch_id)
|
||||||
.ok_or_else(|| anyhow!("could not find branch {branch_id} in status list"))?;
|
.ok_or_else(|| anyhow!("could not find branch {branch_id} in status list"))?;
|
||||||
|
|
||||||
if target_branch.upstream.is_some() && !project_repository.project().ok_with_force_push {
|
if target_branch.upstream.is_some() && !target_branch.allow_rebasing {
|
||||||
// amending to a pushed head commit will cause a force push that is not allowed
|
// amending to a pushed head commit will cause a force push that is not allowed
|
||||||
bail!("force-push is not allowed");
|
bail!("force-push is not allowed");
|
||||||
}
|
}
|
||||||
@ -3508,9 +3512,7 @@ pub fn squash(
|
|||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if pushed_commit_oids.contains(&parent_commit.id())
|
if pushed_commit_oids.contains(&parent_commit.id()) && !branch.allow_rebasing {
|
||||||
&& !project_repository.project().ok_with_force_push
|
|
||||||
{
|
|
||||||
// squashing into a pushed commit will cause a force push that is not allowed
|
// squashing into a pushed commit will cause a force push that is not allowed
|
||||||
bail!("force push not allowed");
|
bail!("force push not allowed");
|
||||||
}
|
}
|
||||||
@ -3604,7 +3606,7 @@ pub fn update_commit_message(
|
|||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if pushed_commit_oids.contains(&commit_id) && !project_repository.project().ok_with_force_push {
|
if pushed_commit_oids.contains(&commit_id) && !branch.allow_rebasing {
|
||||||
// updating the message of a pushed commit will cause a force push that is not allowed
|
// updating the message of a pushed commit will cause a force push that is not allowed
|
||||||
bail!("force push not allowed");
|
bail!("force push not allowed");
|
||||||
}
|
}
|
||||||
@ -3904,7 +3906,7 @@ pub fn create_virtual_branch_from_branch(
|
|||||||
ownership,
|
ownership,
|
||||||
order,
|
order,
|
||||||
selected_for_changes,
|
selected_for_changes,
|
||||||
allow_rebasing: true,
|
allow_rebasing: project_repository.project().ok_with_force_push.into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
vb_state.set_branch(branch.clone())?;
|
vb_state.set_branch(branch.clone())?;
|
||||||
|
Loading…
Reference in New Issue
Block a user