cjohansson / emacs-ssh-deploy

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

.git folder being uploaded #73

Open sternj opened 1 year ago

sternj commented 1 year ago

Under default settings on commit 94b56c, files under .git are being uploaded, even though testing ssh-deploy--file-is-included-p on its own returns nil on an example file.

cjohansson commented 1 year ago

Very strange, I haven't heard anyone have that issue, can you run:

(describe-variable 'ssh-deploy-exclude-list)

And tell me what it's value is.

(When your current-directory is in folder that you use for deployment, like when visiting a file or directory in it)

c308-cnelson commented 1 year ago

I am running into a similar issue. I checked the ssh-deploy-exclude-list variable and it is set to exclude .git and .dir-locals.el but it is still pushing them.

Simon-chevolleau commented 11 months ago

Same here, did someone find a workaround ?

cjohansson commented 11 months ago

What Emacs version are you on? Maybe it is related to that..

Simon-chevolleau commented 11 months ago

I'm using: GNU Emacs v29.1 Doom core v3.0.0-pre Doom modules v23.09.0-pre

I just checked and I have two ssh-deploy installed: ssh-deploy 3.1.16 available gnu Deployment via Tramp, global or per directory. ssh-deploy 20230702.928 available melpa Deployment via Tramp, global or per directory.

Here is my config file (doom emacs) to specify ssh-deploy variables : (after! ssh-deploy (setq ssh-deploy-root-local "/home/simon/gitNantes/") (setq ssh-deploy-root-remote "/ssh:...") (setq ssh-deploy-exclude-list '(".*/\.git/" "\.git/" "\.dir-locals\.el")) (setq ssh-deploy-force-on-explicit-save 0) (setq ssh-deploy-on-explicit-save 0))

cjohansson commented 11 months ago

I think Emacs is a mess when installed via snap in Ubuntu, I tried with Emacs built from source and it was much better.

I tried with Emacs 30.0.50 and ssh-deploy 3.1.16 with following scenario:

test.el contents:

(setq ssh-deploy-root-local "MASKED")
(setq ssh-deploy-root-remote "MASKED")
(setq ssh-deploy-exclude-list '(".*/\.git/" "\.git/" "\.dir-locals\.el"))
(setq ssh-deploy-force-on-explicit-save 0)
(setq ssh-deploy-on-explicit-save 1)

In file test.el I ran M-x eval-buffer

Created a file in root folder and saved, verified that the file was uploaded to remote host. Created a file in folder .git and saved, verified that the file was not uploaded to remote host. Created a file in folder .gut and saved, verified that the file was uploaded to remote host.

Working as expected for me

Simon-chevolleau commented 10 months ago

For my case, I didn't installed via snap, but from source. I changed a little bit my configuration, I was setting ssh-deploy variables in my init file. I now testing .dir-locals.el, but anyway it keeps syncing my .dir-locals.el and also my .git folder.

I'm using the upload module of Doom which is using your package (3.1.16 also) with small configurations (variables and keybinds), but I tried also by installing myself from melpa, with the same problem.

My last hope was settings the absolute path for .dir-locals.el and .git using:

((nil . (
  (ssh-deploy-root-local . "/path/to/local/folder/")
  (ssh-deploy-root-remote . "/path/to/remote/folder/")
  (ssh-deploy-exclude-list . '("/path/to/local/folder/\.git" "/path/to/local/folder/\.dir-locals\.el"))
  (ssh-deploy-async . 1)
  (ssh-deploy-async-with-threads . 1)
  (ssh-deploy-on-explicit-save . 1)
)))

but it gave me this error:

Debugger entered--Lisp error: (wrong-type-argument stringp quote)
  string-match'"/path/to/remote/folder/.dir-locals.el"
  ssh-deploy--file-is-included-p("//path/to/remote/folder/.dir-locals.el" '("/path/to/remote/folder/.git" "/path/to/remote/folder/.dir-locals.el"))
  ssh-deploy-upload-handler()
  funcall-interactively(ssh-deploy-upload-handler)
  call-interactively(ssh-deploy-upload-handler nil nil)
  command-execute(ssh-deploy-upload-handler)

In the end, I tried several things, with no success, I wonder if there is any problems by letting ssh-deploy syncing the git folder and dir-locals file ?

cjohansson commented 10 months ago

Strange, can you describe a scenario step by step how you get the error?

You visit a file and execute the command ssh-deploy-upload-handler ?

cjohansson commented 10 months ago

I don't mean the (wrong-type-argument stringp quote) error, I mean the error where a file that should be excluded is included for deploy

Simon-chevolleau commented 10 months ago

I put myself on root of my project with dired, there I use ssh-deploy-upload-handler.

Here is my configuration:

ssh-deploy-root-local: MASKED
ssh-deploy-root-remote: MASKED
ssh-deploy-debug: 0
ssh-deploy-revision-folder: "/home/simon/.config/emacs/.local/cache/ssh-revisions/"
ssh-deploy-automatically-detect-remote-changes: 1
ssh-deploy-on-explicit-save: 1
ssh-deploy-force-on-explicit-save: 1
ssh-deploy-run-script-on-explicit-save: 0
ssh-deploy-exclude-list: ("/home/simon/gitNantes/umap/.git*" "/home/simon/gitNantes/umap/.git/.*" ".*/envs" ".*/\.envs" ".*/\.git/" "\.git/" "\.dir-locals\.el" "\\.git/" "\\.dir-locals\\.el")
ssh-deploy-async: 0
ssh-deploy-remote-sql-database: nil
ssh-deploy-remote-sql-password: nil
ssh-deploy-remote-sql-port: nil
ssh-deploy-remote-sql-server: nil
ssh-deploy-remote-sql-user: nil
ssh-deploy-remote-shell-executable: nil
ssh-deploy-verbose: 1
ssh-deploy-script: nil
ssh-deploy-async-with-threads: 0

Edit: Is there a way to get the callback when using emacs command, it could help ?

cjohansson commented 10 months ago

Oh are you trying to upload the entire root folder? You expect that the excluded files should not be deployed?

If so I haven't considered that case before

cjohansson commented 10 months ago

When looking through the code I see that when uploading a directory the plugin does not exclude files.. I think this should be considered a bug. If you instead do a sync, files should be excluded properly

Simon-chevolleau commented 10 months ago

Yes, this is exactly what I do. Before I found your package, I usually commited, pushed and pulled on remote server, but this way I had to create a commit every time, this isen't relevant and appropriate for my git historic. Maybe my approach isen't correct ? Do you think this could be easily done when deploying root folder and I guess this bug is also relevant for subfolders ?