-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Roy Razon
committed
Aug 6, 2023
1 parent
1312f13
commit 6504c2c
Showing
12 changed files
with
90 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as git from './git' | ||
import { detectCiProvider } from './ci-providers' | ||
|
||
export type GitAuthor = { name: string; email: string } | ||
|
||
export type GitMetadata = { | ||
branch?: string | ||
commit: string | ||
author: GitAuthor | ||
repoUrl?: string | ||
pullRequestNumber?: number | ||
} | ||
|
||
export type EnvMetadata = { | ||
git?: GitMetadata | ||
} | ||
|
||
const detectGitMetadata = async (): Promise<GitMetadata | undefined> => { | ||
const ciProvider = detectCiProvider() | ||
const branch = await git.gitBranchName() | ||
if (!branch) { | ||
return undefined | ||
} | ||
const commit = ciProvider?.gitCommit() ?? await git.gitCommit() as string | ||
|
||
return { | ||
branch: ciProvider?.branchName() ?? branch, | ||
commit, | ||
author: await git.gitAuthor(commit) as GitAuthor, | ||
pullRequestNumber: ciProvider?.pullRequestNumber(), | ||
repoUrl: ciProvider?.repoUrl() || await git.gitRemoteTrackingBranchUrl(), | ||
} | ||
} | ||
|
||
export const detectEnvMetadata = async (): Promise<EnvMetadata> => ({ | ||
git: await detectGitMetadata(), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters