-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get commit info in Footer and recreate yarn.lock
- Loading branch information
Showing
5 changed files
with
347 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ jobs: | |
with: | ||
path: ./ | ||
node-version: 20.12.2 | ||
package-manager: [email protected] | ||
# package-manager: [email protected] | ||
|
||
deploy: | ||
needs: build-astro | ||
|
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,35 @@ | ||
import { execSync } from 'child_process'; | ||
|
||
export interface GitResult { | ||
time: string; | ||
hash: string; | ||
message: string; | ||
} | ||
|
||
export const getLatestCommitInfo = (): GitResult => { | ||
const separator = '___'; | ||
const command = `git log -1 --pretty=format:"%ad${separator}%h${separator}%s" --date=format:'%Y-%m-%d %H:%M:%S'`; | ||
const output = execSync(command).toString().trim().split(separator); | ||
|
||
if (output.length !== 3) { | ||
throw new Error('Could not parse the latest Git commit output.'); | ||
} | ||
|
||
const result = { | ||
time: output[0], | ||
hash: output[1], | ||
message: output[2], | ||
}; | ||
|
||
return result; | ||
}; | ||
|
||
export const getLatestCommitInfoAsString = (): string => { | ||
const commitInfo = getLatestCommitInfo(); | ||
|
||
const commitInfoString = Object.entries(commitInfo) | ||
.map(([key, value]) => `${key}: ${value}`) | ||
.join(', '); | ||
|
||
return commitInfoString; | ||
}; |
Oops, something went wrong.