Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
(require 'ibuf-ext)
(require 'compile)
(require 'grep)
(require 'xml)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest moving this in the function that uses it, so we don't slow down loading Projectile needlessly.


(eval-when-compile
(require 'find-dired)
(require 'subr-x))
Expand Down Expand Up @@ -346,6 +348,7 @@ See `projectile-register-project-type'."
".pijul" ; Pijul VCS root dir
".sl" ; Sapling VCS root dir
".jj" ; Jujutsu VCS root dir
".osc" ; Osc VCS root dir
)
"A list of files considered to mark the root of a project.
The bottommost (parentmost) match has precedence."
Expand Down Expand Up @@ -441,6 +444,7 @@ is set to `alien'."
".cache"
".clangd"
".sl"
".osc"
".jj")
"A list of directories globally ignored by projectile.

Expand Down Expand Up @@ -796,6 +800,10 @@ Set to nil to disable listing submodules contents."
"Command used by projectile to get the files in a svn project."
:group 'projectile
:type 'string)
(defcustom projectile-osc-command #'projectile-osc-command-files
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a blank line before this.

"Command used by projectile to get the files in a svn project."
:group 'projectile
:type '(function string))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to add a :package-version property.


(defcustom projectile-generic-command
(cond
Expand Down Expand Up @@ -1538,8 +1546,22 @@ Fallback to a generic command when not in a VCS-controlled project."
('svn projectile-svn-command)
('sapling projectile-sapling-command)
('jj projectile-jj-command)
('osc projectile-osc-command)
(_ projectile-generic-command)))


(defun projectile-osc-command-files (&optional root)
"Return files of osc vcs, return either packages or files belonging to package."
(or root (setq root default-directory))
(let* ((files_ (car (xml-parse-file (if (file-exists-p ".osc/_files")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why files_ instead of files?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me a cond might be a better fit than the nested ifs you've opted for.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why files_ instead of files?

Because the file containing the content is called _files and _files as variable name didn't exactly work.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will check using cond for this.

(expand-file-name ".osc/_files")
(if (file-exists-p ".osc/_packages")
(expand-file-name ".osc/_packages")
(error "Directory neither osc package or project"))))))
(entries (or (xml-get-children files_ 'entry)
(xml-get-children files_ 'package))))
(mapcar (lambda (entry) (xml-get-attribute entry 'name)) entries)))

(defun projectile-get-sub-projects-command (vcs)
"Get the sub-projects command for VCS.
Currently that's supported just for Git (sub-projects being Git
Expand Down Expand Up @@ -1636,12 +1658,15 @@ If `command' is nil or an empty string, return nil.
This allows commands to be disabled.

Only text sent to standard output is taken into account."
(when (stringp command)
(when (or (stringp command)
(functionp command))
(let ((default-directory root))
(if (functionp command)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm puzzled by this code, as you call the command, but don't do anything with the result.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do something with the result. The external command if a function is called, returns the list of files and that variable is returned.

(funcall command root)
(with-temp-buffer
(shell-command command t "*projectile-files-errors*")
(let ((shell-output (buffer-substring (point-min) (point-max))))
(split-string (string-trim shell-output) "\0" t))))))
(split-string (string-trim shell-output) "\0" t)))))))

(defun projectile-adjust-files (project vcs files)
"First remove ignored files from FILES, then add back unignored files."
Expand Down Expand Up @@ -3787,6 +3812,7 @@ the variable `projectile-project-root'."
((projectile-file-exists-p (expand-file-name ".svn" project-root)) 'svn)
((projectile-file-exists-p (expand-file-name ".sl" project-root)) 'sapling)
((projectile-file-exists-p (expand-file-name ".jj" project-root)) 'jj)
((projectile-file-exists-p (expand-file-name ".osc" project-root)) 'osc)
;; then we check if there's a VCS marker up the directory tree
;; that covers the case when a project is part of a multi-project repository
;; in those cases you can still the VCS to get a list of files for
Expand All @@ -3801,6 +3827,7 @@ the variable `projectile-project-root'."
((projectile-locate-dominating-file project-root ".svn") 'svn)
((projectile-locate-dominating-file project-root ".sl") 'sapling)
((projectile-locate-dominating-file project-root ".jj") 'jj)
((projectile-locate-dominating-file project-root ".osc") 'osc)
(t 'none)))

(defun projectile--test-name-for-impl-name (impl-file-path)
Expand Down