Skip to content

Handle GPG sign git config for initial commit #5823

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

Merged
merged 2 commits into from
Aug 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/@vue/cli/lib/Creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,22 @@ module.exports = class Creator extends EventEmitter {

// commit initial state
let gitCommitFailed = false
let gpgSign = false
if (shouldInitGit) {
await run('git add -A')
if (isTestOrDebug) {
await run('git', ['config', 'user.name', 'test'])
await run('git', ['config', 'user.email', '[email protected]'])
await run('git', ['config', 'commit.gpgSign', 'false'])
}
gpgSign = await (async () => {
const { stdout: gpgSignConfig } = await run('git', [
'config',
'--get',
'commit.gpgSign'
])
return gpgSignConfig === 'true'
})()
const msg = typeof cliOptions.git === 'string' ? cliOptions.git : 'init'
try {
await run('git', ['commit', '-m', msg, '--no-verify'])
Expand All @@ -277,7 +287,7 @@ module.exports = class Creator extends EventEmitter {

if (gitCommitFailed) {
warn(
`Skipped git commit due to missing username and email in git config.\n` +
`Skipped git commit due to missing username and email in git config${gpgSign ? ' or failed to sign commit' : ''}.\n` +
`You will need to perform the initial commit yourself.\n`
)
}
Expand Down