2024-08-30 10:56:32 +03:00
|
|
|
use gitbutler_branch::VirtualBranchesHandle;
|
2024-08-30 12:27:28 +03:00
|
|
|
use gitbutler_branch_actions::update_workspace_commit;
|
|
|
|
use gitbutler_operating_modes::{
|
|
|
|
assure_open_workspace_mode, INTEGRATION_BRANCH_REF, WORKSPACE_BRANCH_REF,
|
|
|
|
};
|
2024-08-30 10:56:32 +03:00
|
|
|
|
|
|
|
/// Tests that "verify branch" won't complain if we are on the old integration
|
|
|
|
/// branch, and that `update_workspace_commit` will put us back on the a branch
|
|
|
|
/// with the new name.
|
|
|
|
#[test]
|
|
|
|
fn works_on_integration_branch() -> anyhow::Result<()> {
|
2024-09-06 16:18:09 +03:00
|
|
|
let (ctx, _temp_dir) = gitbutler_testsupport::writable::fixture(
|
2024-08-30 10:56:32 +03:00
|
|
|
"for-workspace-migration.sh",
|
|
|
|
"workspace-migration",
|
|
|
|
)?;
|
|
|
|
|
|
|
|
// Check that we are on the old `gitbutler/integration` branch.
|
|
|
|
assert_eq!(
|
|
|
|
ctx.repository().head()?.name(),
|
|
|
|
Some(INTEGRATION_BRANCH_REF)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Should not throw verification error until migration is complete.
|
2024-08-30 12:27:28 +03:00
|
|
|
let result = assure_open_workspace_mode(&ctx);
|
2024-08-30 10:56:32 +03:00
|
|
|
assert!(result.is_ok());
|
|
|
|
|
|
|
|
// Updating workspace commit should put us on the workspace branch.
|
|
|
|
update_workspace_commit(&VirtualBranchesHandle::new(ctx.project().gb_dir()), &ctx)?;
|
|
|
|
assert_eq!(ctx.repository().head()?.name(), Some(WORKSPACE_BRANCH_REF));
|
|
|
|
Ok(())
|
|
|
|
}
|