[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ssh-deploy db73e5b 083/133: Started in new function for
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ssh-deploy db73e5b 083/133: Started in new function for detecting remote changes that should be testable by unit tests |
Date: |
Sat, 27 Mar 2021 14:48:48 -0400 (EDT) |
branch: externals/ssh-deploy
commit db73e5bd7293cd8c998f010f44e33b2eeaa494de
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Started in new function for detecting remote changes that should be
testable by unit tests
---
ssh-deploy-test.el | 52 +++++++++++++++++++++++++---------------------------
ssh-deploy.el | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 27 deletions(-)
diff --git a/ssh-deploy-test.el b/ssh-deploy-test.el
index d3ba791..44c7a8b 100644
--- a/ssh-deploy-test.el
+++ b/ssh-deploy-test.el
@@ -65,7 +65,6 @@
(ssh-deploy-root-local directory-a)
(ssh-deploy-root-remote directory-b)
(ssh-deploy-on-explicit-save 0)
- (ssh-deploy-verbose 0)
(ssh-deploy-debug 0)
(ssh-deploy-async async)
(ssh-deploy-async-with-threads async-with-threads))
@@ -74,7 +73,6 @@
(when (and ssh-deploy-root-local
ssh-deploy-root-remote
ssh-deploy-on-explicit-save
- ssh-deploy-verbose
ssh-deploy-debug
ssh-deploy-async
ssh-deploy-async-with-threads)
@@ -123,7 +121,6 @@
(ssh-deploy-root-local directory-a)
(ssh-deploy-root-remote directory-b)
(ssh-deploy-on-explicit-save 0)
- (ssh-deploy-verbose 0)
(ssh-deploy-debug 0)
(ssh-deploy-async async)
(ssh-deploy-async-with-threads async-with-threads))
@@ -132,7 +129,6 @@
(when (and ssh-deploy-root-local
ssh-deploy-root-remote
ssh-deploy-on-explicit-save
- ssh-deploy-verbose
ssh-deploy-debug
ssh-deploy-async
ssh-deploy-async-with-threads)
@@ -201,7 +197,6 @@
(ssh-deploy-root-local directory-a)
(ssh-deploy-root-remote directory-b)
(ssh-deploy-on-explicit-save 1)
- (ssh-deploy-verbose 0)
(ssh-deploy-debug 0)
(ssh-deploy-async async)
(ssh-deploy-async-with-threads async-with-threads))
@@ -210,7 +205,6 @@
(when (and ssh-deploy-root-local
ssh-deploy-root-remote
ssh-deploy-on-explicit-save
- ssh-deploy-verbose
ssh-deploy-debug
ssh-deploy-async
ssh-deploy-async-with-threads)
@@ -272,27 +266,31 @@
(defun ssh-deploy-test ()
"Run test for plug-in."
- (if (fboundp 'async-start)
- (message "\nNOTE: Running tests for async.el as well since it's
loaded\n")
- (message "\nNOTE: Skipping tests for async.el since it's not loaded\n"))
- (ssh-deploy-test--get-revision-path)
- (ssh-deploy-test--file-is-in-path)
- (ssh-deploy-test--is-not-empty-string)
-
- (ssh-deploy-test--upload 0 0)
- (when (fboundp 'async-start)
- (ssh-deploy-test--upload 1 0))
- (ssh-deploy-test--upload 1 1)
-
- (ssh-deploy-test--download 0 0)
- (when (fboundp 'async-start)
- (ssh-deploy-test--download 1 0))
- (ssh-deploy-test--download 1 1)
-
- (ssh-deploy-test--rename-and-delete 0 0)
- (when (fboundp 'async-start)
- (ssh-deploy-test--rename-and-delete 1 0))
- (ssh-deploy-test--rename-and-delete 1 1))
+ (let ((ssh-deploy-verbose 1)
+ (ssh-deploy-debug 1))
+ (when (and ssh-deploy-verbose
+ ssh-deploy-debug)
+ (if (fboundp 'async-start)
+ (message "\nNOTE: Running tests for async.el as well since it's
loaded\n")
+ (message "\nNOTE: Skipping tests for async.el since it's not
loaded\n"))
+ (ssh-deploy-test--get-revision-path)
+ (ssh-deploy-test--file-is-in-path)
+ (ssh-deploy-test--is-not-empty-string)
+
+ (ssh-deploy-test--upload 0 0)
+ (when (fboundp 'async-start)
+ (ssh-deploy-test--upload 1 0))
+ (ssh-deploy-test--upload 1 1)
+
+ (ssh-deploy-test--download 0 0)
+ (when (fboundp 'async-start)
+ (ssh-deploy-test--download 1 0))
+ (ssh-deploy-test--download 1 1)
+
+ (ssh-deploy-test--rename-and-delete 0 0)
+ (when (fboundp 'async-start)
+ (ssh-deploy-test--rename-and-delete 1 0))
+ (ssh-deploy-test--rename-and-delete 1 1))))
(ssh-deploy-test)
diff --git a/ssh-deploy.el b/ssh-deploy.el
index fa2d436..691d891 100644
--- a/ssh-deploy.el
+++ b/ssh-deploy.el
@@ -731,6 +731,47 @@
(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-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))
+ (root-remote (or root-remote ssh-deploy-root-remote))
+ (exclude-list (or exclude-list ssh-deploy-exclude-list)))
+
+ ;; Is the file inside the local-root and should it not be excluded?
+ (if (and (ssh-deploy--file-is-in-path-p path-local root-local)
+ (ssh-deploy--file-is-included-p path-local exclude-list))
+ (let* ((revision-folder (or revision-folder
ssh-deploy-revision-folder))
+ (revision-path (ssh-deploy--get-revision-path path-local
revision-folder))
+ (path-remote (expand-file-name (ssh-deploy--get-relative-path
root-local path-local) root-remote)))
+
+ ;; 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)
+
+ ;; Local revision exist
+
+ (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))
+
+ ;; 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)))
+
+ ;; File is a directory
+ (list 0 (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)))))
+
;;;###autoload
(defun ssh-deploy-remote-changes (path-local &optional root-local root-remote
async revision-folder exclude-list async-with-threads)
"Check if a local revision for PATH-LOCAL on ROOT-LOCAL and if remote file
has changed on ROOT-REMOTE, do it optionally asynchronously if ASYNC is true,
check for copies in REVISION-FOLDER and skip if path is in EXCLUDE-LIST. Use
multi-threading if ASYNC-WITH-THREADS is above zero."
- [elpa] externals/ssh-deploy bebeaa1 100/133: Updated version to 3.1, (continued)
- [elpa] externals/ssh-deploy bebeaa1 100/133: Updated version to 3.1, Stefan Monnier, 2021/03/27
- [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 <=
- [elpa] externals/ssh-deploy 3a6c3ac 084/133: More work on making detect remote changes unit-testable, Stefan Monnier, 2021/03/27
- [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