Skip to content

Commit

Permalink
Support git worktrees
Browse files Browse the repository at this point in the history
Simple change that also accepts `.git` *files*, instead of only `.git`
directories, as indicating valid git projects. This is a cheap way (i.e. low
performance cost) to detect git worktree repos.

Closes #11
  • Loading branch information
mrcnski committed Jul 25, 2022
1 parent 3a85c41 commit bb8f205
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion my-repo-pins.el
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ If MAX-DEPTH is set to nil, do not use any recursion stop gap."
(let ((full-file (concat dir "/" file)))
;; Don't follow symlinks to other directories.
(when (not (file-symlink-p full-file))
(if (file-directory-p (concat full-file ".git"))
(if (my-repo-pins--is-git-dir full-file)
;; It's a git repo, let's stop here.
(setq projects (nconc projects (list full-file)))
;; It's not a git repo, let's recurse into it.
Expand Down Expand Up @@ -502,6 +502,10 @@ If MAX-DEPTH is set to nil, do not use any recursion stop gap."
(recurse-in-dir dir 0)
(recurse-in-dir dir nil))))

(defun my-repo-pins--is-git-dir (dir)
"Return non-nil if DIR is a git directory."
(file-exists-p (concat (file-name-as-directory dir) ".git")))

(defun my-repo-pins--get-code-root-projects (code-root max-depth)
"Retrieve the projects contained in the CODE-ROOT directory.
We're going to make some hard assumptions about how the
Expand Down

0 comments on commit bb8f205

Please sign in to comment.