mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-28 13:26:16 +03:00
Merge pull request #5036 from gitbutlerapp/add-series-top-base-implementation
Stacking - fixes an issue where its not possible to create additional series for the base of the stack
This commit is contained in:
commit
d262b230a8
@ -415,12 +415,13 @@ fn validate_target(
|
||||
let merge_base = ctx
|
||||
.repository()
|
||||
.merge_base(stack_head, default_target.sha)?;
|
||||
let stack_commits = ctx
|
||||
let mut stack_commits = ctx
|
||||
.repository()
|
||||
.log(stack_head, LogUntil::Commit(merge_base))?
|
||||
.iter()
|
||||
.map(|c| c.id())
|
||||
.collect_vec();
|
||||
stack_commits.insert(0, merge_base);
|
||||
if !stack_commits.contains(&commit.id()) {
|
||||
return Err(anyhow!(
|
||||
"The commit {} is not between the stack head and the stack base",
|
||||
|
@ -94,6 +94,30 @@ fn add_series_top_of_stack() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_series_top_base() -> Result<()> {
|
||||
let (ctx, _temp_dir) = command_ctx("multiple-commits")?;
|
||||
let mut test_ctx = test_ctx(&ctx)?;
|
||||
test_ctx.branch.initialize(&ctx)?;
|
||||
let merge_base = ctx.repository().find_commit(
|
||||
ctx.repository()
|
||||
.merge_base(test_ctx.branch.head, test_ctx.default_target.sha)?,
|
||||
)?;
|
||||
let reference = PatchReference {
|
||||
name: "asdf".into(),
|
||||
target: CommitOrChangeId::CommitId(merge_base.id().to_string()),
|
||||
description: Some("my description".into()),
|
||||
};
|
||||
let result = test_ctx.branch.add_series(&ctx, reference, None);
|
||||
println!("{:?}", result);
|
||||
// Assert persisted
|
||||
assert_eq!(
|
||||
test_ctx.branch,
|
||||
test_ctx.handle.get_branch(test_ctx.branch.id)?
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_multiple_series() -> Result<()> {
|
||||
let (ctx, _temp_dir) = command_ctx("multiple-commits")?;
|
||||
@ -760,6 +784,7 @@ fn test_ctx(ctx: &CommandContext) -> Result<TestContext> {
|
||||
// other_branch: other_branch.clone(),
|
||||
other_commits,
|
||||
handle,
|
||||
default_target: target,
|
||||
})
|
||||
}
|
||||
struct TestContext<'a> {
|
||||
@ -770,4 +795,5 @@ struct TestContext<'a> {
|
||||
#[allow(dead_code)]
|
||||
other_commits: Vec<git2::Commit<'a>>,
|
||||
handle: VirtualBranchesHandle,
|
||||
default_target: gitbutler_branch::Target,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user