Skip to content

Commit cfa99b0

Browse files
authored
test: Fix test failures by specifying initial branch name in git init (#6872)
## What's the problem this PR addresses? This PR adds --initial-branch=master option to ensure consistent test behavior across different development environments. Git has used main as the default branch for quite some time now, while our tests expect master. When I ran the integration tests with my default configuration (using main), they failed due to this mismatch. This change ensures tests pass reliably regardless of local git configuration and lowers the barrier to entry for new contributors! Example error: ```bash FAIL pkg-tests-specs/sources/commands/version/check.test.js (13.598 s) ● Commands › version check › it shouldn't detect a change when pulling master Temporary fixture folder: /private/var/folders/y2/dwrgd4rx32n7phb939mny5p00000gn/T/xfs-46e897df/test Command failed: git checkout master error: pathspec 'master' did not match any file(s) known to git ===== stdout: ``` ``` ===== stderr: ``` error: pathspec 'master' did not match any file(s) known to git ``` ``` <!-- Describe the rationale of your PR. --> <!-- Link all issues that it closes. (Closes/Resolves #xxxx.) --> ... ## How did you fix it? Explicitly set initial branch to master to ensure consistent test behavior. <!-- A detailed description of your implementation. --> ## Checklist <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [x] I will check that all automated PR checks pass before the PR gets reviewed.
1 parent 2212c9f commit cfa99b0

File tree

2 files changed

+2
-2
lines changed
  • packages/acceptance-tests

2 files changed

+2
-2
lines changed

packages/acceptance-tests/pkg-tests-core/sources/utils/exec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const execFile = (
6262
export const execGitInit = async (
6363
options: Options,
6464
) => {
65-
await execFile(`git`, [`init`], options);
65+
await execFile(`git`, [`init`, `--initial-branch=master`], options);
6666
await execFile(`git`, [`config`, `user.email`, `[email protected]`], options);
6767
await execFile(`git`, [`config`, `user.name`, `Your Name`], options);
6868
await execFile(`git`, [`config`, `commit.gpgSign`, `false`], options);

packages/acceptance-tests/pkg-tests-specs/sources/commands/version/check.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function makeVersionCheckEnv(cb) {
173173

174174
await run(`install`);
175175

176-
await git(`init`, `.`);
176+
await git(`init`, `--initial-branch=master`);
177177

178178
// Otherwise we can't always commit
179179
await git(`config`, `user.name`, `John Doe`);

0 commit comments

Comments
 (0)