From c223813d0659c37de08b2e7ea6164d89ebccbfe9 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sun, 22 Sep 2024 20:34:54 -0300 Subject: [PATCH] git: add --commit-msg option --- .../app/__snapshots__/generator.spec.ts.snap | 1 + generators/git/command.ts | 10 ++++++++++ generators/git/generator.ts | 17 ++++++++++------- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/generators/app/__snapshots__/generator.spec.ts.snap b/generators/app/__snapshots__/generator.spec.ts.snap index 39149896843c..aa4c41b7f4a2 100644 --- a/generators/app/__snapshots__/generator.spec.ts.snap +++ b/generators/app/__snapshots__/generator.spec.ts.snap @@ -65,6 +65,7 @@ Options: --client-root-dir Client root --skip-git Skip git repository initialization --force-git Force commit to git repository + --commit-msg Commit changes (implies forceGit) --cypress-coverage Enable Cypress code coverage report generation --cypress-audit Enable cypress-audit/lighthouse report generation --enable-translation Enable translation diff --git a/generators/git/command.ts b/generators/git/command.ts index 78fd48ef5b83..bd6c9078c745 100644 --- a/generators/git/command.ts +++ b/generators/git/command.ts @@ -34,6 +34,16 @@ const command = { }, scope: 'generator', }, + commitMsg: { + description: 'Commit changes (implies forceGit)', + cli: { + type: String, + implies: { + forceGit: true, + }, + }, + scope: 'generator', + }, monorepository: { description: 'Use monorepository', cli: { diff --git a/generators/git/generator.ts b/generators/git/generator.ts index a1445d66b439..274c36a28a59 100644 --- a/generators/git/generator.ts +++ b/generators/git/generator.ts @@ -28,10 +28,11 @@ import { files } from './files.js'; * @extends {BaseGenerator} */ export default class GitGenerator extends BaseGenerator { - gitInitialized; - skipGit; - forceGit; - existingRepository; + gitInitialized!: boolean; + skipGit!: boolean; + forceGit!: boolean; + existingRepository!: boolean; + commitMsg!: string; async beforeQueue() { if (!this.fromBlueprint) { @@ -134,9 +135,11 @@ export default class GitGenerator extends BaseGenerator { } } try { - let commitMsg = existingApplication - ? `Regenerated ${this.jhipsterConfig.baseName} using generator-jhipster@${this.jhipsterConfig.jhipsterVersion}` - : `Initial version of ${this.jhipsterConfig.baseName} generated by generator-jhipster@${this.jhipsterConfig.jhipsterVersion}`; + let commitMsg = + this.commitMsg ?? + (existingApplication + ? `Regenerated ${this.jhipsterConfig.baseName} using generator-jhipster@${this.jhipsterConfig.jhipsterVersion}` + : `Initial version of ${this.jhipsterConfig.baseName} generated by generator-jhipster@${this.jhipsterConfig.jhipsterVersion}`); if (this.jhipsterConfig.blueprints && this.jhipsterConfig.blueprints.length > 0) { const bpInfo = this.jhipsterConfig.blueprints.map(bp => `${bp.name}@${bp.version}`).join(', '); commitMsg += ` with blueprints ${bpInfo}`;