(rawGitArgs, environment, adapterConfig)
| 14 | export default gitCz; |
| 15 | |
| 16 | function gitCz (rawGitArgs, environment, adapterConfig) { |
| 17 | |
| 18 | // See if any override conditions exist. |
| 19 | |
| 20 | // In these very specific scenarios we may want to use a different |
| 21 | // commit strategy than git-cz. For example, in the case of --amend |
| 22 | let parsedCommitizenArgs = commitizenParser.parse(rawGitArgs); |
| 23 | |
| 24 | if (parsedCommitizenArgs.amend) { |
| 25 | // console.log('override --amend in place'); |
| 26 | gitStrategy.default(rawGitArgs, environment); |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | // Now, if we've made it past overrides, proceed with the git-cz strategy |
| 31 | let parsedGitCzArgs = parse(rawGitArgs); |
| 32 | |
| 33 | // Determine if we need to process this commit as a retry instead of a |
| 34 | // normal commit. |
| 35 | let retryLastCommit = rawGitArgs && rawGitArgs[0] === '--retry'; |
| 36 | |
| 37 | // Determine if we need to process this commit using interactive hook mode |
| 38 | // for husky prepare-commit-message |
| 39 | let hookMode = !(typeof parsedCommitizenArgs.hook === 'undefined'); |
| 40 | |
| 41 | let resolvedAdapterConfigPath = resolveAdapterPath(adapterConfig.path); |
| 42 | let resolvedAdapterRootPath = findRoot(resolvedAdapterConfigPath); |
| 43 | let prompter = getPrompter(adapterConfig.path); |
| 44 | let shouldStageAllFiles = rawGitArgs.includes('-a') || rawGitArgs.includes('--all'); |
| 45 | |
| 46 | isClean(process.cwd(), function (error, stagingIsClean) { |
| 47 | if (error) { |
| 48 | throw error; |
| 49 | } |
| 50 | |
| 51 | if (stagingIsClean && !parsedGitCzArgs.includes('--allow-empty')) { |
| 52 | throw new Error('No files added to staging! Did you forget to run git add?'); |
| 53 | } |
| 54 | |
| 55 | // OH GOD IM SORRY FOR THIS SECTION |
| 56 | let adapterPackageJson = getParsedPackageJsonFromPath(resolvedAdapterRootPath); |
| 57 | let cliPackageJson = getParsedPackageJsonFromPath(environment.cliPath); |
| 58 | console.log(`cz-cli@${cliPackageJson.version}, ${adapterPackageJson.name}@${adapterPackageJson.version}\n`); |
| 59 | commit(inquirer, getGitRootPath(), prompter, { |
| 60 | args: parsedGitCzArgs, |
| 61 | disableAppendPaths: true, |
| 62 | emitData: true, |
| 63 | quiet: false, |
| 64 | retryLastCommit, |
| 65 | hookMode |
| 66 | }, function (error) { |
| 67 | if (error) { |
| 68 | throw error; |
| 69 | } |
| 70 | process.exit(0); |
| 71 | }); |
| 72 | }, shouldStageAllFiles); |
| 73 |
nothing calls this directly
no test coverage detected