Skip to content

Commit a6aeb98

Browse files
committed
Wip osc scm support
Signed-off-by: Björn Bidar <[email protected]>
1 parent 30c55d1 commit a6aeb98

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

projectile.el

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
(require 'ibuf-ext)
4242
(require 'compile)
4343
(require 'grep)
44+
(require 'xml)
45+
4446
(eval-when-compile
4547
(require 'find-dired)
4648
(require 'subr-x))
@@ -346,6 +348,7 @@ See `projectile-register-project-type'."
346348
".pijul" ; Pijul VCS root dir
347349
".sl" ; Sapling VCS root dir
348350
".jj" ; Jujutsu VCS root dir
351+
".osc" ; Osc VCS root dir
349352
)
350353
"A list of files considered to mark the root of a project.
351354
The bottommost (parentmost) match has precedence."
@@ -441,6 +444,7 @@ is set to `alien'."
441444
".cache"
442445
".clangd"
443446
".sl"
447+
".osc"
444448
".jj")
445449
"A list of directories globally ignored by projectile.
446450

@@ -796,6 +800,10 @@ Set to nil to disable listing submodules contents."
796800
"Command used by projectile to get the files in a svn project."
797801
:group 'projectile
798802
:type 'string)
803+
(defcustom projectile-osc-command #'projectile-osc-command-files
804+
"Command used by projectile to get the files in a svn project."
805+
:group 'projectile
806+
:type '(function string))
799807

800808
(defcustom projectile-generic-command
801809
(cond
@@ -1538,8 +1546,22 @@ Fallback to a generic command when not in a VCS-controlled project."
15381546
('svn projectile-svn-command)
15391547
('sapling projectile-sapling-command)
15401548
('jj projectile-jj-command)
1549+
('osc projectile-osc-command)
15411550
(_ projectile-generic-command)))
15421551

1552+
1553+
(defun projectile-osc-command-files (&optional root)
1554+
"Return files of osc vcs, return either packages or files belonging to package."
1555+
(or root (setq root default-directory))
1556+
(let* ((files_ (car (xml-parse-file (if (file-exists-p ".osc/_files")
1557+
(expand-file-name ".osc/_files")
1558+
(if (file-exists-p ".osc/_packages")
1559+
(expand-file-name ".osc/_packages")
1560+
(error "Directory neither osc package or project"))))))
1561+
(entries (or (xml-get-children files_ 'entry)
1562+
(xml-get-children files_ 'package))))
1563+
(mapcar (lambda (entry) (xml-get-attribute entry 'name)) entries)))
1564+
15431565
(defun projectile-get-sub-projects-command (vcs)
15441566
"Get the sub-projects command for VCS.
15451567
Currently that's supported just for Git (sub-projects being Git
@@ -1636,12 +1658,15 @@ If `command' is nil or an empty string, return nil.
16361658
This allows commands to be disabled.
16371659

16381660
Only text sent to standard output is taken into account."
1639-
(when (stringp command)
1661+
(when (or (stringp command)
1662+
(functionp command))
16401663
(let ((default-directory root))
1664+
(if (functionp command)
1665+
(funcall command root)
16411666
(with-temp-buffer
16421667
(shell-command command t "*projectile-files-errors*")
16431668
(let ((shell-output (buffer-substring (point-min) (point-max))))
1644-
(split-string (string-trim shell-output) "\0" t))))))
1669+
(split-string (string-trim shell-output) "\0" t)))))))
16451670

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

38063833
(defun projectile--test-name-for-impl-name (impl-file-path)

0 commit comments

Comments
 (0)