Merge pull request #2055 from gitbutlerapp/update-projects-and-apply-branch

Update projects and apply branch
This commit is contained in:
Nikita Galaiko 2023-12-15 11:07:58 +01:00 committed by GitHub
commit cede6734b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View File

@ -288,9 +288,10 @@ pub fn apply_branch(
.find_tree(merged_branch_tree_oid)
.context("failed to find tree")?;
if branch.upstream.is_some() {
// branch was pushed to upstream. create a merge commit to avoid need
// of force pushing.
let ok_with_force_push = project_repository.project().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.
// create a merge commit to avoid the need of force pushing then.
let new_branch_head = project_repository.commit(
user,

View File

@ -2613,9 +2613,19 @@ mod update_base_branch {
repository,
project_id,
controller,
projects,
..
} = Test::default();
projects
.update(&projects::UpdateRequest {
id: project_id,
ok_with_force_push: Some(false),
..Default::default()
})
.await
.unwrap();
controller
.set_base_branch(&project_id, &"refs/remotes/origin/master".parse().unwrap())
.await
@ -3659,6 +3669,15 @@ mod amend {
..
} = Test::default();
projects
.update(&projects::UpdateRequest {
id: project_id,
ok_with_force_push: Some(false),
..Default::default()
})
.await
.unwrap();
controller
.set_base_branch(&project_id, &"refs/remotes/origin/master".parse().unwrap())
.await