From 7241f4fbf74af995db1f632ca47953d04ec446a9 Mon Sep 17 00:00:00 2001 From: David Barnett Date: Fri, 2 Oct 2020 06:08:31 +1300 Subject: [PATCH] test(git-state): tests failing when git init.defaultBranch set (#1692) The tests for git-state assume the default branch is `master`. In git 2.28 support for a global option, `init.defaultBranch`, to change the default branch name which causes git-state tests to fail. --- src/modules/git_state.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/modules/git_state.rs b/src/modules/git_state.rs index 18194ae6..20089f83 100644 --- a/src/modules/git_state.rs +++ b/src/modules/git_state.rs @@ -321,6 +321,16 @@ mod tests { true, )?; + // Ensure on the expected branch. + // If build environment has `init.defaultBranch` global set + // it will default to an unknown branch, so neeed to make & change branch + run_git_cmd( + &["checkout", "-b", "master"], + Some(path), + // command expected to fail if already on the expected branch + false, + )?; + // Write a file on master and commit it write_file("Version A")?; run_git_cmd(&["add", "the_file"], Some(path), true)?;