Skip to content

Commit

Permalink
git: add --commit-msg option
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Sep 22, 2024
1 parent 3eff97c commit c223813
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions generators/app/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Options:
--client-root-dir <value> Client root
--skip-git Skip git repository initialization
--force-git Force commit to git repository
--commit-msg <value> Commit changes (implies forceGit)
--cypress-coverage Enable Cypress code coverage report generation
--cypress-audit Enable cypress-audit/lighthouse report generation
--enable-translation Enable translation
Expand Down
10 changes: 10 additions & 0 deletions generators/git/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
17 changes: 10 additions & 7 deletions generators/git/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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}`;
Expand Down

0 comments on commit c223813

Please sign in to comment.