<commit_before><?php namespace Dan\Setup;


use Dan\Contracts\MessagingContract;
use Dan\Core\Dan;
use Dan\Hooks\HookManager;

class Update {

    protected static $repo = 'dan5';

    /**
     * Returns true if there is an update. False otherwise.
     *
     * @return bool
     */
    public static function check()
    {
        $repo = static::$repo;

        $status = shell_exec("git remote update && git status {$repo}");

        return (strpos($status, "up-to-date") === false) === true;
    }


    /**
     * Updates the bot.
     *
     * @param \Dan\Contracts\MessagingContract $messagingContract
     */
    public static function go(MessagingContract $messagingContract)
    {
        $repo = static::$repo;

        $shell = shell_exec(sprintf("cd %s && git pull origin {$repo}", ROOT_DIR));

        if(strpos($shell, 'composer.lock'))
        {
            shell_exec(sprintf("cd %s && composer install", ROOT_DIR));
        }<commit_msg>Add notification when composer.lock changes<commit_after><?php namespace Dan\Setup;


use Dan\Contracts\MessagingContract;
use Dan\Core\Dan;
use Dan\Hooks\HookManager;

class Update {

    protected static $repo = 'dan5';

    /**
     * Returns true if there is an update. False otherwise.
     *
     * @return bool
     */
    public static function check()
    {
        $repo = static::$repo;

        $status = shell_exec("git remote update && git status {$repo}");

        return (strpos($status, "up-to-date") === false) === true;
    }


    /**
     * Updates the bot.
     *
     * @param \Dan\Contracts\MessagingContract $messagingContract
     */
    public static function go(MessagingContract $messagingContract)
    {
        $repo = static::$repo;

        $shell = shell_exec(sprintf("cd %s && git pull origin {$repo}", ROOT_DIR));

        if(strpos($shell, 'composer.lock'))
        {
            $messagingContract->message("composer.lock changed, installing new packages.");
            shell_exec(sprintf("cd %s && composer install", ROOT_DIR));
        }
{'fraction_non_alphanumeric': 0.137524557956778, 'fraction_numerical': 0.0009823182711198428, 'mean_word_length': 2.5242214532871974, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2841318', 'n_tokens_mistral': 618, 'n_tokens_neox': 596, 'n_words': 153}