From 275e51e4d7b2dacdfc65a2d0d955a639511be250 Mon Sep 17 00:00:00 2001 From: fvrichard Date: Wed, 24 May 2017 13:49:38 +0200 Subject: [PATCH 01/10] Removing backup part from pull function - if database is backed up during pull request, the migration part will import local database backup and not backup pulled from git --- classes/class-revisr-process.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/class-revisr-process.php b/classes/class-revisr-process.php index 3b493081..d5110580 100644 --- a/classes/class-revisr-process.php +++ b/classes/class-revisr-process.php @@ -245,11 +245,11 @@ public function pull() { $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 ); From 1a122221a84583993f4f86224d8dd274f3ab5515 Mon Sep 17 00:00:00 2001 From: fvmartin Date: Wed, 3 Jan 2018 10:54:21 +0100 Subject: [PATCH 02/10] Improving the admin UI a bit --- classes/class-revisr-meta-boxes.php | 4 ++-- revisr.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/class-revisr-meta-boxes.php b/classes/class-revisr-meta-boxes.php index 15fe0669..8adb4bdf 100644 --- a/classes/class-revisr-meta-boxes.php +++ b/classes/class-revisr-meta-boxes.php @@ -69,7 +69,7 @@ public function pending_files() {

-

-
diff --git a/revisr.php b/revisr.php index 7c7409ba..efa8c6be 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+ From 3e1bccd31c58749fb7e123a43b26145b3bbe6f13 Mon Sep 17 00:00:00 2001 From: fvmartin Date: Wed, 3 Jan 2018 11:23:11 +0100 Subject: [PATCH 03/10] Making the staged files list resizable. --- classes/class-revisr-meta-boxes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/class-revisr-meta-boxes.php b/classes/class-revisr-meta-boxes.php index 8adb4bdf..626d425d 100644 --- a/classes/class-revisr-meta-boxes.php +++ b/classes/class-revisr-meta-boxes.php @@ -69,7 +69,7 @@ public function pending_files() {

-

-
From 899203f55eb8e7ef636f21cb38de1fa0dc8bc429 Mon Sep 17 00:00:00 2001 From: fvmartin Date: Tue, 27 Feb 2018 11:28:58 +0100 Subject: [PATCH 04/10] Keep local changes when pulling. --- classes/class-revisr-git.php | 2 +- classes/class-revisr-process.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/class-revisr-git.php b/classes/class-revisr-git.php index a8e68759..f4f26ebf 100644 --- a/classes/class-revisr-git.php +++ b/classes/class-revisr-git.php @@ -622,7 +622,7 @@ public function merge( $branch ) { * @param array $commits The commits we're pulling (used in callback). */ public function pull( $commits = array() ) { - $this->reset(); + //$this->reset(); $pull = $this->run( 'pull', array( '-Xtheirs', '--quiet', $this->remote, $this->branch ), __FUNCTION__, $commits ); return $pull; } diff --git a/classes/class-revisr-process.php b/classes/class-revisr-process.php index d5110580..62fecf63 100644 --- a/classes/class-revisr-process.php +++ b/classes/class-revisr-process.php @@ -238,9 +238,9 @@ public function pull() { Revisr_Admin::verify_nonce( $_REQUEST['revisr_dashboard_nonce'], 'revisr_dashboard_nonce' ); // Fetch the changes so we can compare them. - revisr()->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' ) ); From 7e66d9e435299706e8fa45bb28c781fc6e35cb83 Mon Sep 17 00:00:00 2001 From: fvmartin Date: Tue, 27 Feb 2018 11:29:10 +0100 Subject: [PATCH 05/10] Diff aprearance improvement. --- classes/class-revisr-admin-pages.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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() {
+ + Date: Wed, 1 Jul 2020 16:38:54 +0200 Subject: [PATCH 06/10] commit msg: autosuggest commit message --- assets/js/revisr-staging.js | 4 +++ classes/class-revisr-meta-boxes.php | 51 +++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) 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-meta-boxes.php b/classes/class-revisr-meta-boxes.php index 626d425d..36fc208a 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(); + $unstaged = array(); + $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 ) ) { @@ -76,8 +78,20 @@ public function pending_files() { $result = str_replace( '"', '', $result ); $short_status = substr( $result, 0, 3 ); $file = substr( $result, 3 ); - $status = Revisr_Git::get_status( $short_status ); - echo ""; + $status = Revisr_Git::get_status( $short_status ); + $item = ""; + + if ( preg_match('/wp-content\/plugins\/(.*?)\//', $file, $match) ) { // Match plugin name + if( !isset($commit_items[$status]) ) { + $commit_items[$status][] = $match[1]; + } else if( !in_array($match[1], $commit_items[$status]) ) { + $commit_items[$status][] = $match[1]; + } + echo $item; + } else { // No plugin matched + $unstaged[] = $item; + } + } ?> @@ -93,6 +107,13 @@ public function pending_files() {

@@ -101,6 +122,30 @@ public function pending_files() {
+ $plugins ) { + switch($status) { + case 'Modified': + $commit_msg .=" Updated"; + break; + case 'Untracked': + $commit_msg .=" Added"; + break; + case 'Deleted': + $commit_msg .=" Removed"; + break; + default: + $commit_msg .=" " . $status; + } + $commit_msg .= " - " . implode(",", $plugins); + } + $commit_msg = trim($commit_msg); + ?> + + + + Date: Thu, 2 Jul 2020 12:03:14 +0200 Subject: [PATCH 07/10] auto suggest: improve messages --- classes/class-revisr-meta-boxes.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/class-revisr-meta-boxes.php b/classes/class-revisr-meta-boxes.php index 36fc208a..71a190bb 100644 --- a/classes/class-revisr-meta-boxes.php +++ b/classes/class-revisr-meta-boxes.php @@ -127,13 +127,13 @@ public function pending_files() { foreach( $commit_items as $status => $plugins ) { switch($status) { case 'Modified': - $commit_msg .=" Updated"; + $commit_msg .=" Plugin updates"; break; case 'Untracked': - $commit_msg .=" Added"; + $commit_msg .=" New plugins"; break; case 'Deleted': - $commit_msg .=" Removed"; + $commit_msg .=" Deleted plugins"; break; default: $commit_msg .=" " . $status; From b4e0e63c9f13e7d9402d44fc82f37b34286e09c6 Mon Sep 17 00:00:00 2001 From: Martin Vicenik Date: Thu, 9 Jul 2020 13:32:40 +0200 Subject: [PATCH 08/10] Auto-suggest commit messages for modified plugin files --- assets/js/revisr-staging.js | 4 +++ classes/class-revisr-meta-boxes.php | 51 +++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) 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-meta-boxes.php b/classes/class-revisr-meta-boxes.php index 626d425d..74e67011 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(); + $unstaged = array(); + $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 ) ) { @@ -76,8 +78,20 @@ public function pending_files() { $result = str_replace( '"', '', $result ); $short_status = substr( $result, 0, 3 ); $file = substr( $result, 3 ); - $status = Revisr_Git::get_status( $short_status ); - echo ""; + $status = Revisr_Git::get_status( $short_status ); + $item = ""; + + if ( preg_match('/wp-content\/plugins\/(.*?)\//', $file, $match) ) { // Match plugin name + if( !isset($commit_items[$status]) ) { + $commit_items[$status][] = $match[1]; + } else if( !in_array($match[1], $commit_items[$status]) ) { + $commit_items[$status][] = $match[1]; + } + echo $item; + } else { // No plugin matched + $unstaged[] = $item; + } + } ?> @@ -93,6 +107,13 @@ public function pending_files() {

@@ -101,6 +122,30 @@ 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); + } + $commit_msg = trim($commit_msg); + ?> + + + + Date: Fri, 10 Jul 2020 11:15:12 +0200 Subject: [PATCH 09/10] auto-suggest: detect new files in plugin --- classes/class-revisr-meta-boxes.php | 24 +++++++++++++++++------- revisr.php | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/classes/class-revisr-meta-boxes.php b/classes/class-revisr-meta-boxes.php index 71a190bb..b1302a47 100644 --- a/classes/class-revisr-meta-boxes.php +++ b/classes/class-revisr-meta-boxes.php @@ -81,14 +81,24 @@ public function pending_files() { $status = Revisr_Git::get_status( $short_status ); $item = ""; - if ( preg_match('/wp-content\/plugins\/(.*?)\//', $file, $match) ) { // Match plugin name - if( !isset($commit_items[$status]) ) { - $commit_items[$status][] = $match[1]; - } else if( !in_array($match[1], $commit_items[$status]) ) { - $commit_items[$status][] = $match[1]; + if ( preg_match('/wp-content\/plugins\/((.*?)\/|(.*?)\.php)/', $file, $match) ) { // Match plugin name + $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 considered 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 + } else { // No plugin matched, move to unstaged $unstaged[] = $item; } @@ -138,7 +148,7 @@ public function pending_files() { default: $commit_msg .=" " . $status; } - $commit_msg .= " - " . implode(",", $plugins); + $commit_msg .= " - " . implode(", ", $plugins); } $commit_msg = trim($commit_msg); ?> diff --git a/revisr.php b/revisr.php index efa8c6be..35d8b118 100644 --- a/revisr.php +++ b/revisr.php @@ -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' ); } /** From 7037c5df79616d1202ad75f2a555a969467a4b9f Mon Sep 17 00:00:00 2001 From: Michal Date: Fri, 10 Jul 2020 14:56:16 +0200 Subject: [PATCH 10/10] auto-suggest: improve comments --- classes/class-revisr-meta-boxes.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/classes/class-revisr-meta-boxes.php b/classes/class-revisr-meta-boxes.php index b1302a47..8a70276f 100644 --- a/classes/class-revisr-meta-boxes.php +++ b/classes/class-revisr-meta-boxes.php @@ -61,8 +61,8 @@ public function pending_files() { check_ajax_referer( 'staging_nonce', 'security' ); $output = revisr()->git->status(); $total_pending = count( $output ); - $commit_items = array(); - $unstaged = array(); + $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' ); @@ -81,10 +81,10 @@ public function pending_files() { $status = Revisr_Git::get_status( $short_status ); $item = ""; - if ( preg_match('/wp-content\/plugins\/((.*?)\/|(.*?)\.php)/', $file, $match) ) { // Match plugin name + 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 considered Modified + 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; @@ -118,7 +118,8 @@ public function pending_files() {