mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-30 13:06:10 +03:00
9e236e3469
The reason is that it's unclear if maybe it's there for a good reason, and I don't want to break the complex code in there.
58 lines
1.3 KiB
Rust
58 lines
1.3 KiB
Rust
use std::fs;
|
|
|
|
use gitbutler_branch::{BranchCreateRequest, BranchOwnershipClaims};
|
|
|
|
use super::Test;
|
|
|
|
#[test]
|
|
fn should_unapply_with_commits() {
|
|
let Test {
|
|
project,
|
|
controller,
|
|
repository,
|
|
..
|
|
} = &Test::default();
|
|
|
|
controller
|
|
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
|
|
.unwrap();
|
|
|
|
let branch_id = controller
|
|
.create_virtual_branch(project, &BranchCreateRequest::default())
|
|
.unwrap();
|
|
|
|
fs::write(
|
|
repository.path().join("file.txt"),
|
|
"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n",
|
|
)
|
|
.unwrap();
|
|
controller
|
|
.create_commit(project, branch_id, "test", None, false)
|
|
.unwrap();
|
|
|
|
// change in the committed hunks leads to hunk locking
|
|
fs::write(
|
|
repository.path().join("file.txt"),
|
|
"_\n2\n3\n4\n5\n6\n7\n8\n9\n_\n",
|
|
)
|
|
.unwrap();
|
|
|
|
controller
|
|
.unapply_ownership(
|
|
project,
|
|
&"file.txt:1-5,7-11"
|
|
.parse::<BranchOwnershipClaims>()
|
|
.unwrap(),
|
|
)
|
|
.unwrap_or_else(|err| panic!("{err:?}"));
|
|
|
|
let branch = controller
|
|
.list_virtual_branches(project)
|
|
.unwrap()
|
|
.0
|
|
.into_iter()
|
|
.find(|b| b.id == branch_id)
|
|
.unwrap();
|
|
assert!(branch.files.is_empty());
|
|
}
|