mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
populate on setup
This commit is contained in:
parent
4b68edbcf4
commit
fc07052d57
@ -44,41 +44,46 @@ const gitCommitInfoPlugin = (fullConfig: FullConfigInternal): TestRunnerPlugin =
|
||||
let config: FullConfig;
|
||||
const configDir = fullConfig.configDir;
|
||||
|
||||
async function updateMetdata() {
|
||||
const metadata = config.metadata as MetadataWithCommitInfo;
|
||||
|
||||
const ci = await ciInfo();
|
||||
|
||||
if (!metadata.ci && ci) {
|
||||
debug('ci info', ci);
|
||||
metadata.ci = ci;
|
||||
}
|
||||
|
||||
if (fullConfig.captureGitInfo?.commit || (fullConfig.captureGitInfo?.commit === undefined && ci)) {
|
||||
const git = await gitCommitInfo(configDir).catch(e => print('failed to get git commit info', e));
|
||||
if (git) {
|
||||
debug('commit info', git);
|
||||
metadata.gitCommit = git;
|
||||
}
|
||||
}
|
||||
|
||||
if (fullConfig.captureGitInfo?.diff || (fullConfig.captureGitInfo?.diff === undefined && ci)) {
|
||||
const diffResult = await gitDiff(configDir, ci).catch(e => print('failed to get git diff', e));
|
||||
if (diffResult) {
|
||||
debug(`diff length ${diffResult.length}`);
|
||||
metadata.gitDiff = diffResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let testRun = 0;
|
||||
return {
|
||||
name: 'playwright:git-commit-info',
|
||||
|
||||
setup: async (cfg: FullConfig) => {
|
||||
config = cfg;
|
||||
await updateMetdata();
|
||||
},
|
||||
|
||||
begin: async () => {
|
||||
if (!config)
|
||||
throw new Error('Configuration is missing');
|
||||
|
||||
const metadata = config.metadata as MetadataWithCommitInfo;
|
||||
|
||||
const ci = await ciInfo();
|
||||
|
||||
if (!metadata.ci && ci) {
|
||||
debug('ci info', ci);
|
||||
metadata.ci = ci;
|
||||
}
|
||||
|
||||
if (fullConfig.captureGitInfo?.commit || (fullConfig.captureGitInfo?.commit === undefined && ci)) {
|
||||
const git = await gitCommitInfo(configDir).catch(e => print('failed to get git commit info', e));
|
||||
if (git) {
|
||||
debug('commit info', git);
|
||||
metadata.gitCommit = git;
|
||||
}
|
||||
}
|
||||
|
||||
if (fullConfig.captureGitInfo?.diff || (fullConfig.captureGitInfo?.diff === undefined && ci)) {
|
||||
const diffResult = await gitDiff(configDir, ci).catch(e => print('failed to get git diff', e));
|
||||
if (diffResult) {
|
||||
debug(`diff length ${diffResult.length}`);
|
||||
metadata.gitDiff = diffResult;
|
||||
}
|
||||
}
|
||||
testRun++;
|
||||
if (testRun > 1)
|
||||
await updateMetdata();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user