public static function installGitCommitMessageTemplate(Event $event)
    {
        $templateContent = self::TEMPLATE_CONTENTS;
        $inputOutput = $event->getIO();
        $question = 'Do you want to install and configure the Git ';
        $question .= 'commit message template? ';

        if ($inputOutput->askConfirmation($question, false)) {
            $errorMessage = "Couldn't locate the .git directory. ";
            $errorMessage .= 'Aborting the Git commit message template installation.';

            $gitDirectory = self::getGuardedGitDirectory($errorMessage, $inputOutput);

            if (false === $gitDirectory) {
                return false;
            }

            $templateFile = implode(DIRECTORY_SEPARATOR, [$gitDirectory, self::TEMPLATE_FILENAME]);

            file_put_contents($templateFile, $templateContent);
            $gitConfigureCommand = "git config --add commit.template $templateFile";
            exec($gitConfigureCommand);

            $inputOutput->write('Installed and configured the Git commit message template.');

            if ($inputOutput->isVerbose()) {
                $inputOutput->write('Wrote');
                $inputOutput->write("<comment>$templateContent</comment>");
                $inputOutput->write("into <info>$templateFile</info> and configured the Git commit message template ");
                $inputOutput->write("via <comment>$gitConfigureCommand</comment>.");
            }

            return true;
        }

        $inputOutput->write('Aborted installation and configuration of the Git commit message template.');

        return false;
    }
public static function installGitCommitMessageTemplate(Event $event)
    {
        $templateContent = self::TEMPLATE_CONTENTS;
        $inputOutput = $event->getIO();
        $question = 'Do you want to install and configure the Git ';
        $question .= 'commit message template? ';

        if ($inputOutput->askConfirmation($question, false)) {
            $errorMessage = "Couldn't locate the .git directory. ";
            $errorMessage .= 'Aborting the Git commit message template installation.';

            $gitDirectory = self::getGuardedGitDirectory($errorMessage, $inputOutput);

            if (false === $gitDirectory) {
                return false;
            }

            $templateFile = implode(DIRECTORY_SEPARATOR, [$gitDirectory, self::TEMPLATE_FILENAME]);

            file_put_contents($templateFile, $templateContent);
            $gitConfigureCommand = "git config --add commit.template $templateFile";
            exec($gitConfigureCommand);

            $inputOutput->write('Installed and configured the Git commit message template.');

            if ($inputOutput->isVerbose()) {
                $inputOutput->write('Wrote');
                $inputOutput->write("<comment>$templateContent</comment>");
                $inputOutput->write("into <info>$templateFile</info> and configured the Git commit message template ");
                $inputOutput->write("via <comment>$gitConfigureCommand</comment>.");
            }

            return true;
        }

        $inputOutput->write('Aborted installation and configuration of the Git commit message template.');

        return false;
    }
public static function installGitCommitMessageTemplate ( Event $ event ) { $ templateContent = self :: TEMPLATE_CONTENTS ; $ inputOutput = $ event -> getIO ( ) ; $ question = 'Do you want to install and configure the Git ' ; $ question .= 'commit message template? ' ; if ( $ inputOutput -> askConfirmation ( $ question , false ) ) { $ errorMessage = "Couldn't locate the .git directory. " ; $ errorMessage .= 'Aborting the Git commit message template installation.' ; $ gitDirectory = self :: getGuardedGitDirectory ( $ errorMessage , $ inputOutput ) ; if ( false === $ gitDirectory ) { return false ; } $ templateFile = implode ( DIRECTORY_SEPARATOR , [ $ gitDirectory , self :: TEMPLATE_FILENAME ] ) ; file_put_contents ( $ templateFile , $ templateContent ) ; $ gitConfigureCommand = "git config --add commit.template $templateFile" ; exec ( $ gitConfigureCommand ) ; $ inputOutput -> write ( 'Installed and configured the Git commit message template.' ) ; if ( $ inputOutput -> isVerbose ( ) ) { $ inputOutput -> write ( 'Wrote' ) ; $ inputOutput -> write ( "<comment>$templateContent</comment>" ) ; $ inputOutput -> write ( "into <info>$templateFile</info> and configured the Git commit message template " ) ; $ inputOutput -> write ( "via <comment>$gitConfigureCommand</comment>." ) ; } return true ; } $ inputOutput -> write ( 'Aborted installation and configuration of the Git commit message template.' ) ; return false ; }
Installs and configures the Git commit message
template when confirmed by the user.

@param Event $event The script event

@return bool
Installs and configures the Git commit message template when confirmed by the user .