From 1ecda25ac4582aad957c6943ef607240fa317cd5 Mon Sep 17 00:00:00 2001 From: Juanra GM Date: Wed, 3 Apr 2024 15:51:47 +0200 Subject: [PATCH] fix(cli): add git author --- packages/cli/src/repositories/GitRepository.ts | 5 ++++- packages/cli/src/utils/git.ts | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/repositories/GitRepository.ts b/packages/cli/src/repositories/GitRepository.ts index c3c7bbe..948f5af 100644 --- a/packages/cli/src/repositories/GitRepository.ts +++ b/packages/cli/src/repositories/GitRepository.ts @@ -271,7 +271,10 @@ export class GitRepository extends RepositoryAbstract { size: size.toString(), }); - await git.addTag(meta.name, meta.message); + await git.addTag(meta.name, meta.message, { + userName: "datatruck", + userEmail: "datatruck@localhost", + }); await git.push({ branchName }); await git.pushTags(); diff --git a/packages/cli/src/utils/git.ts b/packages/cli/src/utils/git.ts index 4f7ca4a..b23c1a6 100644 --- a/packages/cli/src/utils/git.ts +++ b/packages/cli/src/utils/git.ts @@ -122,11 +122,23 @@ export class Git { ); } - async addTag(name: string, message?: string) { + async addTag( + name: string, + message?: string, + options: { + allowEmpty?: boolean; + userName?: string; + userEmail?: string; + } = {}, + ) { + const commit = [ + ...(options.userName ? ["-c", `user.name='${options.userName}'`] : []), + ...(options.userEmail ? ["-c", `user.email='${options.userEmail}'`] : []), + ]; if (message) { - await this.exec(["tag", "-a", name, "-m", message]); + await this.exec([...commit, "tag", "-a", name, "-m", message]); } else { - await this.exec(["tag", name]); + await this.exec([...commit, "tag", name]); } }