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.
This commit is contained in:
David Barnett 2020-10-02 06:08:31 +13:00 committed by GitHub
parent e9d3811ac8
commit 7241f4fbf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -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)?;