cjohansson / emacs-ssh-deploy

A deployment plugin via Tramp for Emacs.
GNU General Public License v3.0
154 stars 6 forks source link

Deploying a predefined set of files #68

Closed UndeadKernel closed 1 year ago

UndeadKernel commented 4 years ago

I was wondering if it is possible to upload a set of files every time I call ssh-deploy-upload-handler instead of only the currently opened file. Imagine this setting: I have an org file with some code blocks. These blocks are tangled into their own scripts. When I upload the "main" org file, I also want to upload the associated tangled files.

What is the "canonical" way to copy a whole project (e.g., a git repo) onto a remote location while running an ssh-deploy-* command within a open file of the project?

cjohansson commented 4 years ago

Yeah I would define a upload script that uploads the specific files, I’ll give an example when I’m at my computer

cjohansson commented 4 years ago

Here is an example, I haven't tested it, please let me know if it doesn't work.

.dir-locals.el contents:

((nil . (
  (ssh-deploy-root-local . "/Users/username/Web/MySite/")
  (ssh-deploy-root-remote . "/ssh:myuser@myserver.com|sudo:web@myserver.com:/var/www/MySite/")
  (ssh-deploy-script .
                   (lambda()
                     (let ((buffer-file-name "myFirstFile.txt"))
                       (ssh-deploy-upload-handler))
                     (let ((buffer-file-name "mySecondFile.txt"))
                       (ssh-deploy-upload-handler))))
)))

When you run the (ssh-deploy-run-deploy-script-handler) the script should upload both files.

UndeadKernel commented 1 year ago

Sorry for being late to the party :D

The solution you propose works when I manually call ssh-deploy-run-deploy-script-handler. Is it possible to configure ssh-deploy to call the script automatically when I save a file? My .dir-locals.el file looks like the following and the script is not run automatically on save:

((nil . ((ssh-deploy-root-local . "/home/user/app/")
         (ssh-deploy-root-remote . "/ssh:user:/home/user/app/")
         (ssh-deploy-on-explicit-save . 1)
         (ssh-deploy-script .  (lambda()
                                 (let ((buffer-file-name "client"))
                                   (ssh-deploy-upload-handler))
                                 (let ((buffer-file-name "server"))
                                   (ssh-deploy-upload-handler)))))))
cjohansson commented 1 year ago

I see, I could add a setting for that if you want, like ssh-deploy-run-script-on-save or something?

UndeadKernel commented 1 year ago

Such a setting/feature would be more than welcome @cjohansson.

cjohansson commented 1 year ago

This should be fixed in commit 0e93dd6044a7f3fcd2938da39522719d7c779790