Skip to content

Commit d1c47a1

Browse files
authored
fix: remove unexpected line break (#520)
1 parent 6244517 commit d1c47a1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/core/git.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function getRepoInfo(root: string, extra: Options['git'] = {}) {
1111
return undefined;
1212
}
1313

14-
const [branch, currentCommit, commiter, tags, github, result] = await Promise.all([
14+
const [branch, currentCommit, committer, tags, github, result] = await Promise.all([
1515
getBranch(git),
1616
getCommit(git),
1717
getCommitter(git),
@@ -27,7 +27,7 @@ export async function getRepoInfo(root: string, extra: Options['git'] = {}) {
2727
return {
2828
...branch,
2929
...currentCommit,
30-
...commiter,
30+
...committer,
3131
...tags,
3232
...github,
3333
...Object.fromEntries(result)
@@ -71,6 +71,10 @@ async function getCommit(git: SimpleGit) {
7171
}
7272
}
7373

74+
function removeLineBreak(str: string) {
75+
return str.replace(/[\s\r\n]+$/, '');
76+
}
77+
7478
async function getCommitter(git: SimpleGit) {
7579
try {
7680
const [committer, committerEmail, committerDate] = await Promise.all([
@@ -79,9 +83,9 @@ async function getCommitter(git: SimpleGit) {
7983
git.show(['-s', '--format=%cd'])
8084
]);
8185
return {
82-
committer,
83-
committerEmail,
84-
committerDate
86+
committer: removeLineBreak(committer),
87+
committerEmail: removeLineBreak(committerEmail),
88+
committerDate: removeLineBreak(committerDate)
8589
};
8690
} catch (error) {
8791
return {

0 commit comments

Comments
 (0)