Skip to content

Commit 93d4cc5

Browse files
authored
feat: add optional commit ID to reporter configuration (#31)
1 parent d0e2ed9 commit 93d4cc5

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ reporter: [
122122
repositoryName: "ctrf-json", // Optional: Specify the repository name.
123123
repositoryUrl: "https://gh.io", // Optional: Specify the repository url.
124124
branchName: "main", // Optional: Specify the branch name.
125+
commit: "abc123", // Optional: Specify the commit id.
125126
testEnvironment: "staging" // Optional: Specify the test environment (e.g. staging, production).
126127
}]
127128
],

src/generate-report.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ interface ReporterConfigOptions {
3838
repositoryName?: string | undefined
3939
repositoryUrl?: string | undefined
4040
branchName?: string | undefined
41+
commit?: string | undefined
4142
testEnvironment?: string | undefined
4243
}
4344

@@ -70,6 +71,7 @@ class GenerateCtrfReport implements Reporter {
7071
repositoryName: config?.repositoryName ?? undefined,
7172
repositoryUrl: config?.repositoryUrl ?? undefined,
7273
branchName: config?.branchName ?? undefined,
74+
commit: config?.commit ?? undefined,
7375
testEnvironment: config?.testEnvironment ?? undefined,
7476
}
7577

@@ -320,6 +322,9 @@ class GenerateCtrfReport implements Reporter {
320322
if (reporterConfigOptions.branchName !== undefined) {
321323
this.ctrfEnvironment.branchName = reporterConfigOptions.branchName
322324
}
325+
if (reporterConfigOptions.commit !== undefined) {
326+
this.ctrfEnvironment.commit = reporterConfigOptions.commit
327+
}
323328
if (reporterConfigOptions.testEnvironment !== undefined) {
324329
this.ctrfEnvironment.testEnvironment =
325330
reporterConfigOptions.testEnvironment

types/ctrf.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export interface CtrfEnvironment {
7676
repositoryName?: string
7777
repositoryUrl?: string
7878
branchName?: string
79+
commit?: string
7980
testEnvironment?: string
8081
extra?: Record<string, any>
8182
}

0 commit comments

Comments
 (0)