Add test to ensure old integration branch doesn't throw

This commit is contained in:
Mattias Granlund 2024-08-30 10:56:32 +03:00
parent 0db82ea38c
commit 85ebc4ea78
4 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -eu -o pipefail
CLI=${1:?The first argument is the GitButler CLI}
git init remote
(cd remote
echo first > file
git add . && git commit -m "init"
)
export GITBUTLER_CLI_DATA_DIR=../user/gitbutler/app-data
git clone remote workspace-migration
(cd workspace-migration
$CLI project add --switch-to-workspace "$(git rev-parse --symbolic-full-name @{u})"
$CLI branch create virtual
# Start the test on the old integration branch.
git checkout -b gitbutler/integration
)

View File

@ -82,6 +82,7 @@ mod update_base_branch;
mod update_commit_message;
mod upstream;
mod verify_branch;
mod workspace_migration;
#[test]
fn resolve_conflict_flow() {

View File

@ -0,0 +1,31 @@
use gitbutler_branch::VirtualBranchesHandle;
use gitbutler_branch_actions::{update_workspace_commit, verify_branch};
use gitbutler_operating_modes::{INTEGRATION_BRANCH_REF, WORKSPACE_BRANCH_REF};
/// 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<()> {
let ctx = gitbutler_testsupport::read_only::fixture(
"for-workspace-migration.sh",
"workspace-migration",
)?;
let mut guard = ctx.project().exclusive_worktree_access();
let perm = guard.write_permission();
// 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.
let result = verify_branch(&ctx, perm);
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(())
}

View File

@ -11,7 +11,7 @@ pub mod commands;
pub const WORKSPACE_BRANCH_REF: &str = "refs/heads/gitbutler/workspace";
/// Previous workspace reference, delete after transition.
const INTEGRATION_BRANCH_REF: &str = "refs/heads/gitbutler/integration";
pub const INTEGRATION_BRANCH_REF: &str = "refs/heads/gitbutler/integration";
/// To prevent clients hitting the "looks like you've moved away from..."
/// after upgrading to a version using the new gitbutler/workspace branch