Skip to content

Commit 85ebc4e

Browse files
committed
Add test to ensure old integration branch doesn't throw
1 parent 0db82ea commit 85ebc4e

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
set -eu -o pipefail
3+
CLI=${1:?The first argument is the GitButler CLI}
4+
5+
git init remote
6+
(cd remote
7+
echo first > file
8+
git add . && git commit -m "init"
9+
)
10+
11+
export GITBUTLER_CLI_DATA_DIR=../user/gitbutler/app-data
12+
git clone remote workspace-migration
13+
(cd workspace-migration
14+
$CLI project add --switch-to-workspace "$(git rev-parse --symbolic-full-name @{u})"
15+
$CLI branch create virtual
16+
# Start the test on the old integration branch.
17+
git checkout -b gitbutler/integration
18+
)

crates/gitbutler-branch-actions/tests/virtual_branches/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ mod update_base_branch;
8282
mod update_commit_message;
8383
mod upstream;
8484
mod verify_branch;
85+
mod workspace_migration;
8586

8687
#[test]
8788
fn resolve_conflict_flow() {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use gitbutler_branch::VirtualBranchesHandle;
2+
use gitbutler_branch_actions::{update_workspace_commit, verify_branch};
3+
use gitbutler_operating_modes::{INTEGRATION_BRANCH_REF, WORKSPACE_BRANCH_REF};
4+
5+
/// Tests that "verify branch" won't complain if we are on the old integration
6+
/// branch, and that `update_workspace_commit` will put us back on the a branch
7+
/// with the new name.
8+
#[test]
9+
fn works_on_integration_branch() -> anyhow::Result<()> {
10+
let ctx = gitbutler_testsupport::read_only::fixture(
11+
"for-workspace-migration.sh",
12+
"workspace-migration",
13+
)?;
14+
let mut guard = ctx.project().exclusive_worktree_access();
15+
let perm = guard.write_permission();
16+
17+
// Check that we are on the old `gitbutler/integration` branch.
18+
assert_eq!(
19+
ctx.repository().head()?.name(),
20+
Some(INTEGRATION_BRANCH_REF)
21+
);
22+
23+
// Should not throw verification error until migration is complete.
24+
let result = verify_branch(&ctx, perm);
25+
assert!(result.is_ok());
26+
27+
// Updating workspace commit should put us on the workspace branch.
28+
update_workspace_commit(&VirtualBranchesHandle::new(ctx.project().gb_dir()), &ctx)?;
29+
assert_eq!(ctx.repository().head()?.name(), Some(WORKSPACE_BRANCH_REF));
30+
Ok(())
31+
}

crates/gitbutler-operating-modes/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub mod commands;
1111
pub const WORKSPACE_BRANCH_REF: &str = "refs/heads/gitbutler/workspace";
1212

1313
/// Previous workspace reference, delete after transition.
14-
const INTEGRATION_BRANCH_REF: &str = "refs/heads/gitbutler/integration";
14+
pub const INTEGRATION_BRANCH_REF: &str = "refs/heads/gitbutler/integration";
1515

1616
/// To prevent clients hitting the "looks like you've moved away from..."
1717
/// after upgrading to a version using the new gitbutler/workspace branch

0 commit comments

Comments
 (0)