diff options
author | David Barnett <david@barnett.net.nz> | 2020-10-02 06:08:31 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-01 19:08:31 +0200 |
commit | 7241f4fbf74af995db1f632ca47953d04ec446a9 (patch) | |
tree | c1bda890d72d40e115089618ec21e999cd0d7870 | |
parent | e9d3811ac8935ef7fc9153567aaedfa2adbbac02 (diff) |
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.
-rw-r--r-- | src/modules/git_state.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/modules/git_state.rs b/src/modules/git_state.rs index 18194ae6d..20089f838 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)?; |