Skip to content

Commit

Permalink
fix: remove unexpected line break (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
lawvs authored Jan 26, 2024
1 parent 6244517 commit d1c47a1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/core/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function getRepoInfo(root: string, extra: Options['git'] = {}) {
return undefined;
}

const [branch, currentCommit, commiter, tags, github, result] = await Promise.all([
const [branch, currentCommit, committer, tags, github, result] = await Promise.all([
getBranch(git),
getCommit(git),
getCommitter(git),
Expand All @@ -27,7 +27,7 @@ export async function getRepoInfo(root: string, extra: Options['git'] = {}) {
return {
...branch,
...currentCommit,
...commiter,
...committer,
...tags,
...github,
...Object.fromEntries(result)
Expand Down Expand Up @@ -71,6 +71,10 @@ async function getCommit(git: SimpleGit) {
}
}

function removeLineBreak(str: string) {
return str.replace(/[\s\r\n]+$/, '');
}

async function getCommitter(git: SimpleGit) {
try {
const [committer, committerEmail, committerDate] = await Promise.all([
Expand All @@ -79,9 +83,9 @@ async function getCommitter(git: SimpleGit) {
git.show(['-s', '--format=%cd'])
]);
return {
committer,
committerEmail,
committerDate
committer: removeLineBreak(committer),
committerEmail: removeLineBreak(committerEmail),
committerDate: removeLineBreak(committerDate)
};
} catch (error) {
return {
Expand Down

0 comments on commit d1c47a1

Please sign in to comment.