[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ssh-deploy 3a6c3ac 084/133: More work on making detect
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ssh-deploy 3a6c3ac 084/133: More work on making detect remote changes unit-testable |
Date: |
Sat, 27 Mar 2021 14:48:49 -0400 (EDT) |
branch: externals/ssh-deploy
commit 3a6c3acaafdd8d44285aa4e7a6369945945ad4c7
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More work on making detect remote changes unit-testable
---
ssh-deploy.el | 67 +++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 45 insertions(+), 22 deletions(-)
diff --git a/ssh-deploy.el b/ssh-deploy.el
index 691d891..988e3c7 100644
--- a/ssh-deploy.el
+++ b/ssh-deploy.el
@@ -161,38 +161,38 @@
(defcustom ssh-deploy-on-explicit-save 1
"Boolean variable if deploy should be made on explicit save, 1 by default."
- :type 'boolean)
+ :type 'integer)
(put 'ssh-deploy-on-explicit-save 'permanent-local t)
(put 'ssh-deploy-on-explicit-save 'safe-local-variable 'integerp)
(defcustom ssh-deploy-debug 0
"Boolean variable if debug messages should be shown, 0 by default."
- :type 'boolean)
+ :type 'integer)
(put 'ssh-deploy-debug 'permanent-local t)
(put 'ssh-deploy-debug 'safe-local-variable 'integerp)
;; TODO This flag needs to work better, you should not miss any useful
notifications when this is on
(defcustom ssh-deploy-verbose 1
"Boolean variable if debug messages should be shown, 1 by default."
- :type 'boolean)
+ :type 'integer)
(put 'ssh-deploy-verbose 'permanent-local t)
(put 'ssh-deploy-verbose 'safe-local-variable 'integerp)
(defcustom ssh-deploy-async 0
"Boolean variable if asynchronous method for transfers should be used, 0 by
default."
- :type 'boolean)
+ :type 'integer)
(put 'ssh-deploy-async 'permanent-local t)
(put 'ssh-deploy-async 'safe-local-variable 'integerp)
(defcustom ssh-deploy-async-with-threads 0
"Boolean variable if asynchronous method should use threads if available, 0
by default."
- :type 'boolean)
+ :type 'integer)
(put 'ssh-deploy-async-with-threads 'permanent-local t)
(put 'ssh-deploy-async-with-threads 'safe-local-variable 'integerp)
(defcustom ssh-deploy-async-with-threads 0
"Boolean variable if asynchronous method should use threads if available, 0
by default."
- :type 'boolean)
+ :type 'integer)
(put 'ssh-deploy-async-with-threads 'permanent-local t)
(put 'ssh-deploy-async-with-threads 'safe-local-variable 'integerp)
@@ -204,7 +204,7 @@
(defcustom ssh-deploy-automatically-detect-remote-changes 1
"Detect remote changes and store base revisions automatically, 1 by default."
- :type 'boolean)
+ :type 'integer)
(put 'ssh-deploy-automatically-detect-remote-changes 'permanent-local t)
(put 'ssh-deploy-automatically-detect-remote-changes 'safe-local-variable
'integerp)
@@ -731,7 +731,32 @@
(when (or (> (length (nth 4 diff)) 0) (> (length (nth 5 diff)) 0) (>
(length (nth 7 diff)) 0))
(ssh-deploy--diff-directories-present diff directory-a directory-b
on-explicit-save debug async async-with-threads revision-folder remote-changes
exclude-list))))))
-;; TODO Should optimize and unit-test this function
+(defun ssh-deploy--remote-changes-post-executor (response verbose)
+ "Process RESPONSE from `ssh-deploy--remote-changes-data' with flags:
VERBOSE."
+ (pcase (nth 0 response)
+ (1
+ ;; File is outside root or excluded from it
+ (when (> verbose 0) (message (nth 1 response))))
+ (2
+ ;; File is a directory ignore
+ (when (> verbose 0) (message (nth 1 response))))
+ (3
+ ;; Remote file doesn't exist)
+ (when (> verbose 0) (message (nth 1 response))))
+ (4
+ ;; Remote file has not changed
+ (when (> verbose 0) (message (nth 1 response))))
+ (5
+ ;; Remote file has changed in comparison with local revision
+ (display-warning 'ssh-deploy (nth 1 response) :warning))
+ (6
+ ;; Remote file has changed not in comparison with local file
+ (copy-file (nth 2 response) (nth 3 response) t t t t)
+ (when (> verbose 0) (message (nth 1 response))))
+ (7
+ ;; Remote file has changed in comparison with local file
+ (display-warning 'ssh-deploy (nth 1 response) :warning))))
+
(defun ssh-deploy--remote-changes-data (path-local &optional root-local
root-remote revision-folder exclude-list)
"Check if a local revision for PATH-LOCAL on ROOT-LOCAL and if remote file
has changed on ROOT-REMOTE, check for copies in REVISION-FOLDER and skip if
path is in EXCLUDE-LIST. Should only return status-code and message."
(let ((root-local (or root-local ssh-deploy-root-local))
@@ -748,29 +773,27 @@
;; Is the file a regular file?
(if (not (file-directory-p path-local))
- ;; Does a local revision of the file exist?
- (if (file-exists-p revision-path)
+ ;; Does remote file exists?
+ (if (file-exists-p path-remote)
- ;; Local revision exist
+ ;; Does a local revision of the file exist?
+ (if (file-exists-p revision-path)
- (if (file-exists-p path-remote)
(if (ediff-same-file-contents revision-path path-remote)
- (list 0 (format "Remote file '%s' has not changed."
path-remote) path-local)
- (list 1 (format "Remote file '%s' has changed please
download or diff." path-remote) path-local))
- (list 0 (format "Remote file '%s' doesn't exist."
path-remote) path-local))
+ (list 4 (format "Remote file '%s' has not changed."
path-remote) path-local)
+ (list 5 (format "Remote file '%s' has changed compared
to local revision, please download or diff." path-remote) path-local
revision-path))
- ;; Does remote file exist?
- (if (file-exists-p path-remote)
(if (ediff-same-file-contents path-local path-remote)
- (list 0 (format "Remote file '%s' has not changed.
SHOULD create base revision." path-remote) path-local)
- (list 1 (format "Remote file '%s' has changed please
download or diff." path-remote) path-local))
- (list 0 (format "Remote file '%s' doesn't exist."
path-remote) path-local)))
+ (list 6 (format "Remote file '%s' has not changed
compared to local file, created local revision." path-remote) path-local
revision-path)
+ (list 7 (format "Remote file '%s' has changed compared
to local file, please download or diff." path-remote) path-local path-remote)))
+
+ (list 3 (format "Remote file '%s' doesn't exist." path-remote)
path-local))
;; File is a directory
- (list 0 (format "File %s is a directory, ignoring remote changes
check." path-local) path-local)))
+ (list 2 (format "File '%s' is a directory, ignoring remote changes
check." path-local) path-local)))
;; File is not inside root or is excluded from it
- (list 0 (format "File %s is not in root or is excluded from it."
path-local)))))
+ (list 1 (format "File '%s' is not in root or is excluded from it."
path-local) path-local))))
;;;###autoload
(defun ssh-deploy-remote-changes (path-local &optional root-local root-remote
async revision-folder exclude-list async-with-threads)
- [elpa] externals/ssh-deploy c4fd187 039/133: Deletion working from diff-mode, (continued)
- [elpa] externals/ssh-deploy c4fd187 039/133: Deletion working from diff-mode, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 88300e3 043/133: Improved wording of remote change detection, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy e08b8bb 044/133: Improved documentation, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy b480db9 055/133: Changed (when (not)) to (unless), Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 31cb94d 060/133: Added compile command to makefile and added a .gitignore file, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy d03bd70 068/133: Added unit-test for uploads, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 95e823a 074/133: Fixed issue with byte-compilation warning in new unit tests, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy f233e2e 075/133: Removed checks for ediff-same-file-contents function since it's built-in in Emacs, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 336833f 076/133: Got (autoload) working inside asynchronous process, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy db73e5b 083/133: Started in new function for detecting remote changes that should be testable by unit tests, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 3a6c3ac 084/133: More work on making detect remote changes unit-testable,
Stefan Monnier <=
- [elpa] externals/ssh-deploy 7d578da 088/133: Passing unit test for asynchronous change detection, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 20a87ab 099/133: Added async.el to travis test, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 761eb11 098/133: Updated Travis to use emacs version snapshot, 25.1 and 26.1 via EVM, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 0111640 108/133: Removed unnecessary async autoloads, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy ea734f5 104/133: Added note, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 49ae447 097/133: Fixed Travis build status logo, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy a5aa5f6 093/133: Run only async test with threads if threads are available, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy b8f976a 116/133: Passing verbose flag to diff files function, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy e1507fe 119/133: Create FUNDING.yml, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 37a15c6 118/133: fix: ".git" matching, Stefan Monnier, 2021/03/27