record pr and commit diffs
This commit is contained in:
parent
a68750da04
commit
ff5509f1a7
|
|
@ -95,7 +95,18 @@ const GitCommitInfoView: React.FC<{ info: GitCommitInfo }> = ({ info }) => {
|
|||
<div className='hbox m-2 mt-1'>
|
||||
<div className='mr-1'>{author}</div>
|
||||
<div title={longTimestamp}> on {shortTimestamp}</div>
|
||||
{info['ci.link'] && <><span className='mx-2'>·</span><a href={info['ci.link']} target='_blank' rel='noopener noreferrer' title='CI/CD logs'>logs</a></>}
|
||||
{info['ci.link'] && (
|
||||
<>
|
||||
<span className='mx-2'>·</span>
|
||||
<a href={info['ci.link']} target='_blank' rel='noopener noreferrer' title='CI/CD logs'>logs</a>
|
||||
</>
|
||||
)}
|
||||
{info['pull.link'] && (
|
||||
<>
|
||||
<span className='mx-2'>·</span>
|
||||
<a href={info['pull.link']} target='_blank' rel='noopener noreferrer'>pull request</a>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{!!info['revision.link'] && <a href={info['revision.link']} target='_blank' rel='noopener noreferrer'>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ export interface GitCommitInfo {
|
|||
'revision.timestamp'?: number | Date;
|
||||
'revision.link'?: string;
|
||||
'revision.diff'?: string;
|
||||
'pull.id'?: string;
|
||||
'pull.link'?: string;
|
||||
'pull.diff'?: string;
|
||||
'pull.base'?: string;
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ interface GitCommitInfoPluginOptions {
|
|||
directory?: string;
|
||||
}
|
||||
|
||||
function linksFromEnv(): Pick<GitCommitInfo, 'revision.link' | 'ci.link' | 'pull.link' | 'pull.base'> {
|
||||
const out: { 'revision.link'?: string; 'ci.link'?: string; 'pull.link'?: string; 'pull.base'?: string; } = {};
|
||||
function linksFromEnv() {
|
||||
const out: Partial<GitCommitInfo> = {};
|
||||
// Jenkins: https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
|
||||
if (process.env.BUILD_URL)
|
||||
out['ci.link'] = process.env.BUILD_URL;
|
||||
|
|
@ -60,8 +60,8 @@ function linksFromEnv(): Pick<GitCommitInfo, 'revision.link' | 'ci.link' | 'pull
|
|||
if (process.env.GITHUB_SERVER_URL && process.env.GITHUB_REPOSITORY && process.env.GITHUB_RUN_ID)
|
||||
out['ci.link'] = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
|
||||
if (process.env.GITHUB_REF_NAME && process.env.GITHUB_REF_NAME.endsWith('/merge')) {
|
||||
const pullId = process.env.GITHUB_REF_NAME.substring(0, process.env.GITHUB_REF_NAME.indexOf('/merge'));
|
||||
out['pull.link'] = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/pull/${pullId}`;
|
||||
out['pull.id'] = process.env.GITHUB_REF_NAME.substring(0, process.env.GITHUB_REF_NAME.indexOf('/merge'));
|
||||
out['pull.link'] = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/pull/${out['pull.id']}`;
|
||||
out['pull.base'] = process.env.GITHUB_BASE_REF;
|
||||
}
|
||||
return out;
|
||||
|
|
|
|||
|
|
@ -1213,6 +1213,8 @@ for (const useIntermediateMergeReport of [true, false] as const) {
|
|||
await execGit(['init']);
|
||||
await execGit(['config', '--local', 'user.email', 'shakespeare@example.local']);
|
||||
await execGit(['config', '--local', 'user.name', 'William']);
|
||||
await execGit(['add', 'playwright.config.ts']);
|
||||
await execGit(['commit', '-m', 'init']);
|
||||
await execGit(['add', '*.ts']);
|
||||
await execGit(['commit', '-m', 'chore(html): make this test look nice']);
|
||||
|
||||
|
|
@ -1222,6 +1224,8 @@ for (const useIntermediateMergeReport of [true, false] as const) {
|
|||
GITHUB_RUN_ID: 'example-run-id',
|
||||
GITHUB_SERVER_URL: 'https://playwright.dev',
|
||||
GITHUB_SHA: 'example-sha',
|
||||
GITHUB_REF_NAME: '42/merge',
|
||||
GITHUB_BASE_REF: 'HEAD~1',
|
||||
});
|
||||
|
||||
await showReport();
|
||||
|
|
@ -1232,6 +1236,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
|
|||
- 'link "chore(html): make this test look nice"'
|
||||
- text: /^William <shakespeare@example.local> on/
|
||||
- link "logs"
|
||||
- link "pull request"
|
||||
- link /^[a-f0-9]{7}$/
|
||||
- text: 'foo: value1 bar: {"prop":"value2"} baz: ["value3",123]'
|
||||
`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue