update packages
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
;;; magit-repos.el --- Listing repositories -*- lexical-binding:t -*-
|
||||
|
||||
;; Copyright (C) 2008-2023 The Magit Project Contributors
|
||||
;; Copyright (C) 2008-2025 The Magit Project Contributors
|
||||
|
||||
;; Author: Jonas Bernoulli <jonas@bernoul.li>
|
||||
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
|
||||
;; Author: Jonas Bernoulli <emacs.magit@jonas.bernoulli.dev>
|
||||
;; Maintainer: Jonas Bernoulli <emacs.magit@jonas.bernoulli.dev>
|
||||
|
||||
;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
@@ -56,27 +56,29 @@ This option controls which repositories are being listed by
|
||||
:link '(info-link "(magit)Repository List")
|
||||
:group 'magit-modes)
|
||||
|
||||
(defcustom magit-repolist-mode-hook '(hl-line-mode)
|
||||
(defcustom magit-repolist-mode-hook (list #'hl-line-mode)
|
||||
"Hook run after entering Magit-Repolist mode."
|
||||
:package-version '(magit . "2.9.0")
|
||||
:group 'magit-repolist
|
||||
:type 'hook
|
||||
:get #'magit-hook-custom-get
|
||||
:options '(hl-line-mode))
|
||||
:options (list #'hl-line-mode))
|
||||
|
||||
(defcustom magit-repolist-columns
|
||||
'(("Name" 25 magit-repolist-column-ident nil)
|
||||
("Version" 25 magit-repolist-column-version
|
||||
`(("Name" 25 ,#'magit-repolist-column-ident
|
||||
())
|
||||
("Version" 25 ,#'magit-repolist-column-version
|
||||
((:sort magit-repolist-version<)))
|
||||
("B<U" 3 magit-repolist-column-unpulled-from-upstream
|
||||
("B<U" 3 ,#'magit-repolist-column-unpulled-from-upstream
|
||||
(;; (:help-echo "Upstream changes not in branch")
|
||||
(:right-align t)
|
||||
(:sort <)))
|
||||
("B>U" 3 magit-repolist-column-unpushed-to-upstream
|
||||
("B>U" 3 ,#'magit-repolist-column-unpushed-to-upstream
|
||||
(;; (:help-echo "Local changes not in upstream")
|
||||
(:right-align t)
|
||||
(:sort <)))
|
||||
("Path" 99 magit-repolist-column-path nil))
|
||||
("Path" 99 ,#'magit-repolist-column-path
|
||||
()))
|
||||
"List of columns displayed by `magit-list-repositories'.
|
||||
|
||||
Each element has the form (HEADER WIDTH FORMAT PROPS).
|
||||
@@ -116,9 +118,9 @@ than 9."
|
||||
(sexp :tag "Value"))))))
|
||||
|
||||
(defcustom magit-repolist-column-flag-alist
|
||||
'((magit-untracked-files . "N")
|
||||
(magit-unstaged-files . "U")
|
||||
(magit-staged-files . "S"))
|
||||
`((,#'magit-untracked-files . "N")
|
||||
(,#'magit-unstaged-files . "U")
|
||||
(,#'magit-staged-files . "S"))
|
||||
"Association list of predicates and flags for `magit-repolist-column-flag'.
|
||||
|
||||
Each element is of the form (FUNCTION . FLAG). Each FUNCTION is
|
||||
@@ -178,14 +180,14 @@ repositories are displayed."
|
||||
"Fetch all marked or listed repositories."
|
||||
(interactive (list (magit-repolist--get-repos ?*)))
|
||||
(run-hooks 'magit-credential-hook)
|
||||
(magit-repolist--mapc (apply-partially #'magit-run-git "remote" "update")
|
||||
(magit-repolist--mapc (##magit-run-git "remote" "update")
|
||||
repos "Fetching in %s..."))
|
||||
|
||||
(defun magit-repolist-find-file-other-frame (repos file)
|
||||
"Find a file in all marked or listed repositories."
|
||||
(interactive (list (magit-repolist--get-repos ?*)
|
||||
(read-string "Find file in repositories: ")))
|
||||
(magit-repolist--mapc (apply-partially #'find-file-other-frame file) repos))
|
||||
(magit-repolist--mapc (##find-file-other-frame file) repos))
|
||||
|
||||
(defun magit-repolist--ensure-padding ()
|
||||
"Set `tabulated-list-padding' to 2, unless that is already non-zero."
|
||||
@@ -240,17 +242,16 @@ If it contains \"%s\" then the directory is substituted for that."
|
||||
(let ((base default-directory)
|
||||
(len (length repos))
|
||||
(i 0))
|
||||
(mapc (lambda (repo)
|
||||
(let ((default-directory
|
||||
(file-name-as-directory (expand-file-name repo base))))
|
||||
(if msg
|
||||
(let ((msg (concat (format "(%s/%s) " (cl-incf i) len)
|
||||
(format msg default-directory))))
|
||||
(message msg)
|
||||
(funcall fn)
|
||||
(message (concat msg "done")))
|
||||
(funcall fn))))
|
||||
repos)))
|
||||
(dolist (repo repos)
|
||||
(let ((default-directory
|
||||
(file-name-as-directory (expand-file-name repo base))))
|
||||
(if msg
|
||||
(let ((msg (concat (format "(%s/%s) " (cl-incf i) len)
|
||||
(format msg default-directory))))
|
||||
(message msg)
|
||||
(funcall fn)
|
||||
(message (concat msg "done")))
|
||||
(funcall fn))))))
|
||||
|
||||
;;;; Mode
|
||||
|
||||
@@ -265,9 +266,11 @@ If it contains \"%s\" then the directory is substituted for that."
|
||||
|
||||
(define-derived-mode magit-repolist-mode tabulated-list-mode "Repos"
|
||||
"Major mode for browsing a list of Git repositories."
|
||||
:interactive nil
|
||||
:group 'magit-repolist
|
||||
(setq-local x-stretch-cursor nil)
|
||||
(setq tabulated-list-padding 0)
|
||||
(add-hook 'tabulated-list-revert-hook #'magit-repolist-refresh nil t)
|
||||
(setq-local tabulated-list-revert-hook (list #'magit-repolist-refresh t))
|
||||
(setq imenu-prev-index-position-function
|
||||
#'magit-repolist--imenu-prev-index-position)
|
||||
(setq imenu-extract-index-name-function #'tabulated-list-get-id))
|
||||
@@ -323,9 +326,9 @@ If it contains \"%s\" then the directory is substituted for that."
|
||||
""))
|
||||
magit-repolist-columns)))))
|
||||
(magit-list-repos-uniquify
|
||||
(--map (cons (file-name-nondirectory (directory-file-name it))
|
||||
it)
|
||||
(magit-list-repos)))))
|
||||
(mapcar (##cons (file-name-nondirectory (directory-file-name %))
|
||||
%)
|
||||
(magit-list-repos)))))
|
||||
(message "Listing repositories...")
|
||||
(tabulated-list-init-header)
|
||||
(tabulated-list-print t)
|
||||
@@ -379,7 +382,8 @@ Usually this is just its basename."
|
||||
(when (match-end 2)
|
||||
(magit--put-face (match-beginning 2) (match-end 2) 'bold v))
|
||||
(when (match-end 4)
|
||||
(magit--put-face (match-beginning 4) (match-end 4) 'error v))
|
||||
(magit--put-face (or (match-beginning 3) (match-beginning 4))
|
||||
(match-end 4) 'error v))
|
||||
(when (and (equal (match-string 2 v) "1")
|
||||
(string-match-p magit-repolist-column-version-resume-regexp
|
||||
(magit-rev-format "%s")))
|
||||
@@ -497,18 +501,18 @@ instead."
|
||||
(or (magit-toplevel) default-directory)))))
|
||||
|
||||
(defun magit-list-repos ()
|
||||
(cl-mapcan (pcase-lambda (`(,dir . ,depth))
|
||||
(magit-list-repos-1 dir depth))
|
||||
magit-repository-directories))
|
||||
(mapcan (pcase-lambda (`(,dir . ,depth))
|
||||
(magit-list-repos-1 dir depth))
|
||||
magit-repository-directories))
|
||||
|
||||
(defun magit-list-repos-1 (directory depth)
|
||||
(cond ((file-readable-p (expand-file-name ".git" directory))
|
||||
(list (file-name-as-directory directory)))
|
||||
((and (> depth 0) (magit-file-accessible-directory-p directory))
|
||||
(--mapcat (and (file-directory-p it)
|
||||
(magit-list-repos-1 it (1- depth)))
|
||||
(directory-files directory t
|
||||
directory-files-no-dot-files-regexp t)))))
|
||||
((and (> depth 0) (file-accessible-directory-p directory))
|
||||
(mapcan (##and (file-directory-p %)
|
||||
(magit-list-repos-1 % (1- depth)))
|
||||
(directory-files directory t
|
||||
directory-files-no-dot-files-regexp t)))))
|
||||
|
||||
(defun magit-list-repos-uniquify (alist)
|
||||
(let (result (dict (make-hash-table :test #'equal)))
|
||||
@@ -519,22 +523,24 @@ instead."
|
||||
(if (length= value 1)
|
||||
(push (cons key (car value)) result)
|
||||
(setq result
|
||||
(append result
|
||||
(magit-list-repos-uniquify
|
||||
(--map (cons (concat
|
||||
key "\\"
|
||||
(file-name-nondirectory
|
||||
(directory-file-name
|
||||
(substring it 0 (- (1+ (length key)))))))
|
||||
it)
|
||||
value))))))
|
||||
(append
|
||||
result
|
||||
(magit-list-repos-uniquify
|
||||
(mapcar (lambda (v)
|
||||
(cons (concat
|
||||
key "\\"
|
||||
(file-name-nondirectory
|
||||
(directory-file-name
|
||||
(substring v 0 (- (1+ (length key)))))))
|
||||
v))
|
||||
value))))))
|
||||
dict)
|
||||
result))
|
||||
|
||||
(defun magit-repos-alist ()
|
||||
(magit-list-repos-uniquify
|
||||
(--map (cons (file-name-nondirectory (directory-file-name it)) it)
|
||||
(magit-list-repos))))
|
||||
(mapcar (##cons (file-name-nondirectory (directory-file-name %)) %)
|
||||
(magit-list-repos))))
|
||||
|
||||
;;; _
|
||||
(provide 'magit-repos)
|
||||
|
||||
Reference in New Issue
Block a user