Skip to content

Commit

Permalink
[Fix bbatsov#952] Exclude out-of-project VCS submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
timcharper committed Jan 22, 2016
1 parent 8c6b4b4 commit 020d920
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
(require 'ibuf-ext)
(require 'compile)
(require 'grep)
(require 'cl)

(eval-when-compile
(defvar ag-ignore-list)
Expand Down Expand Up @@ -867,16 +868,28 @@ Files are returned as relative paths to the project root."
((eq vcs 'git) projectile-git-submodule-command)
(t ""))))

(defun projectile-get-all-sub-projects (project)
"Get all sub-projects for a given projects.
PROJECT is base directory to start search recursively."
(defun projectile-get-sub-projects (project)
"Get immediate sub-projects for a given project. Does not recurse.
It is assumed that `project` will end with an appropriate path delimiter, such as '/' or a '\'"
(let* ((default-directory project)
;; search for sub-projects under current project `project'
(submodules (mapcar
(lambda (s)
(file-name-as-directory (expand-file-name s default-directory)))
(projectile-files-via-ext-command (projectile-get-sub-projects-command)))))
(file-name-as-directory (expand-file-name s project)))
(projectile-files-via-ext-command (projectile-get-sub-projects-command))))
(project-child-folder-regex (concat "^" (regexp-quote default-directory))))

;; If project root is inside of an SCM folder, but not actually an
;; SCM root itself, external paths will leak in. Let's remove them
(-remove (lambda (path)
(string-match-p project-child-folder-regex
path))
submodules)))

(defun projectile-get-all-sub-projects (project)
"Get all sub-projects for a given project.
PROJECT is base directory to start search recursively."
(let ((submodules (projectile-get-sub-projects project)))
(cond
((null submodules)
nil)
Expand Down

0 comments on commit 020d920

Please sign in to comment.