-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
simplify git options and config #30229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,10 +26,7 @@ import type { Config as GitConfig, Options as GitOptions } from './types.js'; | |
|
||
export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> { | ||
gitInitialized!: boolean; | ||
skipGit!: boolean; | ||
forceGit!: boolean; | ||
existingRepository!: boolean; | ||
commitMsg!: string; | ||
|
||
async beforeQueue() { | ||
if (!this.fromBlueprint) { | ||
|
@@ -40,19 +37,14 @@ export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> { | |
get initializing() { | ||
return this.asInitializingTaskGroup({ | ||
async checkGit() { | ||
if (!this.skipGit) { | ||
if (!this.options.skipGit) { | ||
const gitInstalled = (await this.createGit().version()).installed; | ||
if (!gitInstalled) { | ||
this.log.warn('Git repository will not be created, as Git is not installed on your system'); | ||
this.skipGit = true; | ||
this.gitInitialized = false; | ||
} | ||
} | ||
}, | ||
async initializeMonorepository() { | ||
if (!this.skipGit && this.jhipsterConfig.monorepository) { | ||
await this.initializeGitRepository(); | ||
} | ||
}, | ||
Comment on lines
-51
to
-55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Monorepository is very hard to handle. Monorepository is initialized before composing with applications generators, so generators will detect they are inside a monorepository. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've seen that, but is there a need to have git repo initialized twice? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, |
||
}); | ||
} | ||
|
||
|
@@ -63,7 +55,7 @@ export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> { | |
get preparing() { | ||
return this.asPreparingTaskGroup({ | ||
async preparing() { | ||
if (!this.skipGit) { | ||
if (!this.options.skipGit) { | ||
// Force write .yo-rc.json to disk, it's used to check if the application is regenerated | ||
this.jhipsterConfig.monorepository ??= undefined; | ||
} | ||
|
@@ -91,7 +83,7 @@ export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> { | |
return this.asPostWritingTaskGroup({ | ||
/** Husky commit hook install at install priority requires git to be initialized */ | ||
async initGitRepo() { | ||
if (!this.skipGit && !this.jhipsterConfig.monorepository) { | ||
if (!this.options.skipGit && !this.jhipsterConfig.monorepository) { | ||
await this.initializeGitRepository(); | ||
} | ||
}, | ||
|
@@ -106,25 +98,25 @@ export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> { | |
return this.asEndTaskGroup({ | ||
/** Initial commit to git repository after package manager install for package-lock.json */ | ||
async gitCommit() { | ||
if (this.skipGit) return; | ||
if (this.options.skipGit) return; | ||
if (!this.gitInitialized) { | ||
this.log.warn('The generated application could not be committed to Git, as a Git repository could not be initialized.'); | ||
return; | ||
} | ||
|
||
const commitFiles = async () => { | ||
this.debug('Committing files to git'); | ||
this.log.debug('Committing files to git'); | ||
const git = this.createGit(); | ||
const repositoryRoot = await git.revparse(['--show-toplevel']); | ||
const result = await git.log(['-n', '1', '--', '.yo-rc.json']).catch(() => ({ total: 0 })); | ||
const existingApplication = result.total > 0; | ||
if (existingApplication && !this.forceGit) { | ||
if (existingApplication && !this.options.forceGit) { | ||
this.log.info( | ||
`Found .yo-rc.json in Git from ${repositoryRoot}. So we assume this is application regeneration. Therefore automatic Git commit is not done. You can do Git commit manually.`, | ||
); | ||
return; | ||
} | ||
if (!this.forceGit) { | ||
if (!this.options.forceGit) { | ||
const statusResult = await git.status(); | ||
if (statusResult.staged.length > 0) { | ||
this.log.verboseInfo(`The repository ${repositoryRoot} has staged files, skipping commit.`); | ||
|
@@ -133,7 +125,7 @@ export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> { | |
} | ||
try { | ||
let commitMsg = | ||
this.commitMsg ?? | ||
this.options.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}`); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ export type ConfigAll = Simplify< | |
microfrontends?: { baseName: string }[]; | ||
} & ExportStoragePropertiesFromCommand<typeof import('../../generators/app/command.ts').default> & | ||
ExportStoragePropertiesFromCommand<typeof import('../../generators/bootstrap-application-base/command.ts').default> & | ||
ExportStoragePropertiesFromCommand<typeof import('../../generators/git/command.ts').default> & | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no reason to remove git from configAll There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not used anymore in other generators than git (has been move to git options) (considered as resolved: better being part of workspaceoptions) : played with inheritance to have workspaceoptions & config in the inheritance chain There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All config/properties/application is only used by BaseApplicationGeneratorAll and testing helpers. |
||
ExportStoragePropertiesFromCommand<typeof import('../../generators/jdl/command.ts').default> & | ||
ExportStoragePropertiesFromCommand<typeof import('../../generators/languages/command.ts').default> & | ||
ExportStoragePropertiesFromCommand<typeof import('../../generators/liquibase/command.ts').default> & | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ export type OptionsAll = Simplify< | |
ExportGeneratorOptionsFromCommand<typeof import('../../generators/base/command.ts').default> & | ||
ExportGeneratorOptionsFromCommand<typeof import('../../generators/bootstrap-application-base/command.ts').default> & | ||
ExportGeneratorOptionsFromCommand<typeof import('../../generators/client/command.ts').default> & | ||
ExportGeneratorOptionsFromCommand<typeof import('../../generators/git/command.ts').default> & | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no reason to remove git from optionsAll There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not used anymore in other generators than git (has been move) (considered as resolved: better being part of workspaceoptions) |
||
ExportGeneratorOptionsFromCommand<typeof import('../../generators/java/generators/bootstrap/command.ts').default> & | ||
ExportGeneratorOptionsFromCommand<typeof import('../../generators/java/generators/build-tool/command.ts').default> & | ||
ExportGeneratorOptionsFromCommand<typeof import('../../generators/java/generators/graalvm/command.ts').default> & | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,5 @@ export type ApplicationAll<E extends EntityAll = EntityAll> = BaseApplication<E> | |
ClientApplication<E> & | ||
DockerApplication & | ||
LiqbuibaseApplication<E> & | ||
ExportApplicationPropertiesFromCommand<typeof import('../../generators/git/command.ts').default> & | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no reason to remove git from propertiesAll There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not used anymore in other generators than git (has been move) (considered as resolved: better being part of workspaceoptions) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All config/properties/application is only used by BaseApplicationGeneratorAll and testing helpers. |
||
ExportApplicationPropertiesFromCommand<typeof import('../../generators/project-name/command.ts').default> & | ||
ExportApplicationPropertiesFromCommand<typeof import('../../generators/spring-boot/command.ts').default>; |
Uh oh!
There was an error while loading. Please reload this page.