generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
A lot of tests fail if your default system language is not English. You can reproduce the error with for example:
LANGUAGE=de yarn test
This error is the same as this one. We fixed that one using regular expressions but I think It would be better to set the default language to English before running the tests.
I think we could set the LANGUAGE
env var in the test helper function:
export async function newSimpleGit(baseDir: string): Promise<SimpleGit> {
return simpleGit(baseDir)
}
Like this:
export async function newSimpleGit(baseDir: string): Promise<SimpleGit> {
const git = simpleGit(baseDir)
git.env({
LANGUAGE: 'en'
})
return git
}
That works for unit tests but not for e2e tests because the GitRepo
class relies on git messages to detect a repository without commits. In fact, the action would not work on systems not working in English.
export class GitRepo {
...
async hasCommits(): Promise<boolean> {
// TODO: find a better way to check if the repo has commits
const currentBranch = await this.getCurrentBranch()
try {
await this.log()
} catch (err) {
if (
(err as GitResponseError).message.includes(
`fatal: your current branch '${currentBranch}' does not have any commits yet`
)
) {
// No commits yet
return false
} else {
throw err
}
}
return true
}
...
}
We have to change that method too. The same message in German is:
fatal: Ihr aktueller Branch 'main' hat noch keine Commits.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working