diff --git a/assets/js/revisr-staging.js b/assets/js/revisr-staging.js index c91b85f9..b4cfad70 100755 --- a/assets/js/revisr-staging.js +++ b/assets/js/revisr-staging.js @@ -45,6 +45,10 @@ jQuery(document).ready(function($) { $.post(ajaxurl, data, function(response) { document.getElementById('pending_files_result').innerHTML = response; + old_title = document.getElementById('title'); + new_title = document.getElementById('title-tmp'); + document.getElementById('titlewrap').replaceChild(new_title, old_title); + new_title.id = 'title'; }); } diff --git a/classes/class-revisr-admin-pages.php b/classes/class-revisr-admin-pages.php index e6e77e84..eabb5c83 100644 --- a/classes/class-revisr-admin-pages.php +++ b/classes/class-revisr-admin-pages.php @@ -277,6 +277,19 @@ public function site5_notice() { + + reset(); + //$this->reset(); $pull = $this->run( 'pull', array( '-Xtheirs', '--quiet', $this->remote, $this->branch ), __FUNCTION__, $commits ); return $pull; } diff --git a/classes/class-revisr-meta-boxes.php b/classes/class-revisr-meta-boxes.php index 15fe0669..8a70276f 100644 --- a/classes/class-revisr-meta-boxes.php +++ b/classes/class-revisr-meta-boxes.php @@ -61,7 +61,9 @@ public function pending_files() { check_ajax_referer( 'staging_nonce', 'security' ); $output = revisr()->git->status(); $total_pending = count( $output ); - $text = sprintf( __( 'There are %s untracked files that can be added to this commit.', 'revisr' ), $total_pending, revisr()->git->branch ); + $commit_items = array(); // Categorize the changed files into categories for automated commit message creation + $unstaged = array(); // Store changes that do not match wp-content/plugins/plugin-name/ or wp-content/plugins/plugin-name.php + $text = sprintf( __( 'There are %s untracked files that can be added to this commit.', 'revisr' ), $total_pending, revisr()->git->branch ); echo "
" . $text . "

"; _e( 'Use the boxes below to select the files to include in this commit. Only files in the "Staged Files" section will be included.
Double-click files marked as "Modified" to view the changes to the file.

', 'revisr' ); if ( is_array( $output ) ) { @@ -69,15 +71,37 @@ public function pending_files() {

- {$file} [{$status}]"; + $status = Revisr_Git::get_status( $short_status ); + $item = ""; + + if ( preg_match('/wp-content\/plugins\/((.*?)\/|(.*?)\.php)/', $file, $match) ) { // Match plugin name, example : wp-content/plugins/plugin-name/ or wp-content/plugins/plugin-name.php + $plugin_matched = !empty($match[2]) ? $match[2] : $match[3]; + + if( $status == 'Untracked' && isset($commit_items['Modified']) ) { // New file or folder created in existing plugin is not added to commit_items if plugin name is in modified + if(in_array($plugin_matched, $commit_items['Modified'])) { + echo $item; + continue; + } + } + + if( !isset($commit_items[$status]) ) { // No status yet + $commit_items[$status][] = $plugin_matched; + } else if( !in_array($plugin_matched, $commit_items[$status]) ) { // Prevent duplicates + $commit_items[$status][] = $plugin_matched; + } + + echo $item; + } else { // No plugin matched, move to unstaged + $unstaged[] = $item; + } + } ?> @@ -92,7 +116,15 @@ public function pending_files() {

- +
@@ -101,6 +133,31 @@ public function pending_files() {
+ $plugins ) { + switch($status) { + case 'Modified': + $commit_msg .=" Plugin updates"; + break; + case 'Untracked': + $commit_msg .=" New plugins"; + break; + case 'Deleted': + $commit_msg .=" Deleted plugins"; + break; + default: + $commit_msg .=" " . $status; + } + $commit_msg .= " - " . implode(", ", $plugins); // Build commit message from plugin names and statuses + } + $commit_msg = trim($commit_msg); + ?> + + + + git->reset(); + //revisr()->git->reset(); revisr()->git->fetch(); - + // Build an array of the commits we don't have locally. $commits_since = revisr()->git->run( 'log', array( revisr()->git->branch . '..' . revisr()->git->remote . '/' . revisr()->git->branch, '--pretty=oneline' ) ); // Maybe backup database. - if ( revisr()->git->get_config( 'revisr', 'import-pulls' ) === 'true' ) { - revisr()->db->backup(); - $undo_hash = revisr()->git->current_commit(); - revisr()->git->set_config( 'revisr', 'last-db-backup', $undo_hash ); - } + // if ( revisr()->git->get_config( 'revisr', 'import-pulls' ) === 'true' ) { + // revisr()->db->backup(); + // $undo_hash = revisr()->git->current_commit(); + // revisr()->git->set_config( 'revisr', 'last-db-backup', $undo_hash ); + // } // Fires before the changes are pulled. do_action( 'revisr_pre_pull', $commits_since ); diff --git a/revisr.php b/revisr.php index 7c7409ba..35d8b118 100644 --- a/revisr.php +++ b/revisr.php @@ -7,8 +7,8 @@ * * Plugin Name: Revisr * Plugin URI: https://revisr.io/ - * Description: A plugin that allows users to manage WordPress websites with Git repositories. - * Version: 2.0.2 + * Description: A plugin that allows users to manage WordPress websites with Git repositories. FV: Removing the db backup from pull function and improving the admin UI a bit + * Version: 100.2.0.2.fv * Author: Expanded Fronts, LLC * Author URI: http://expandedfronts.com/ * License: GPL-3.0+ @@ -228,7 +228,7 @@ private function define_constants() { define( 'REVISR_URL', plugin_dir_url( REVISR_FILE ) ); // The current version of the plugin. - define( 'REVISR_VERSION', '2.0.2' ); + define( 'REVISR_VERSION', '2.0.3' ); } /**