libraries/Github_updater.php
/**
     * Performs an update if one is available.
     *
     * @return bool true on success, false on failure
     */
Performs an update if one is available.
@return bool true on success, false on failure
Performs an update if one is available . @return bool true on success false on failure
public function update()
    {
        $branches = json_decode($this->_connect(self::API_URL.$this->ci->config->item('github_user').'/'.$this->ci->config->item('github_repo').'/branches'));
        $hash = $branches[0]->commit->sha;
        if($hash !== $this->ci->config->item('current_commit'))
        {
            $commits = json_decode($this->_connect(self::API_URL.$this->ci->config->item('github_user').'/'.$this->ci->config->item('github_repo').'/compare/'.$this->ci->config->item('current_commit').'...'.$hash));
            $files = $commits->files;
            if($dir = $this->_get_and_extract($hash))
            {
                foreach($files as $file)
                {
                    if(!$this->_is_ignored($file->filename))
                    {
                        if($file->status === 'removed')unlink($file->filename);
                        else copy($dir.'/'.$file->filename, $file->filename);
                    }
                }
                if($this->ci->config->item('clean_update_files'))
                {
                    shell_exec("rm -rf {$dir}");
                    unlink("{$hash}.zip");
                }
                $this->_set_config_hash($hash);
                return true;
            }
        }
        return false;
    }
public function update ( ) { $ branches = json_decode ( $ this -> _connect ( self :: API_URL . $ this -> ci -> config -> item ( 'github_user' ) . '/' . $ this -> ci -> config -> item ( 'github_repo' ) . '/branches' ) ) ; $ hash = $ branches [ 0 ] -> commit -> sha ; if ( $ hash !== $ this -> ci -> config -> item ( 'current_commit' ) ) { $ commits = json_decode ( $ this -> _connect ( self :: API_URL . $ this -> ci -> config -> item ( 'github_user' ) . '/' . $ this -> ci -> config -> item ( 'github_repo' ) . '/compare/' . $ this -> ci -> config -> item ( 'current_commit' ) . '...' . $ hash ) ) ; $ files = $ commits -> files ; if ( $ dir = $ this -> _get_and_extract ( $ hash ) ) { foreach ( $ files as $ file ) { if ( ! $ this -> _is_ignored ( $ file -> filename ) ) { if ( $ file -> status === 'removed' ) unlink ( $ file -> filename ) ; else copy ( $ dir . '/' . $ file -> filename , $ file -> filename ) ; } } if ( $ this -> ci -> config -> item ( 'clean_update_files' ) ) { shell_exec ( " rm -rf  { $ dir } " ) ; unlink ( " { $ hash } .zip " ) ; } $ this -> _set_config_hash ( $ hash ) ; return true ; } } return false ; }
Performs an update if one is available.
Performs an update if one is available .
//Loop through the list of changed files for this commit //If the file isn't in the ignored list then perform the update //If the status is removed then delete the file //Otherwise copy the file from the update. //Clean up //Update the current commit hash