From d29163e00313690435b2baacc770a734598dd956 Mon Sep 17 00:00:00 2001 From: Benjamin Orthen Date: Fri, 8 Sep 2023 12:05:14 +0200 Subject: [PATCH] Add elpa--core-files to get more exact devel-versions for core packages --- elpa-admin.el | 51 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/elpa-admin.el b/elpa-admin.el index 2c2d2aeab7..57dfee8f18 100644 --- a/elpa-admin.el +++ b/elpa-admin.el @@ -908,20 +908,49 @@ of the current `process-environment'. Return the modified copy." 0))) (encode-time (list s mi h d mo y nil nil zs)))) +(defun elpaa--core-files (pkg-spec) + "Get a list of core files (and only files) for PKG-SPEC. +Core folders are recursively searched, excluded files are ignored." + (when-let + ((core (elpaa--spec-get pkg-spec :core))) + (let* + ((excludes (elpaa--spec-get pkg-spec :excludes)) + (emacs-repo-root (expand-file-name "emacs")) + (default-directory emacs-repo-root) + (file-patterns + (if (listp core) + core + (list core))) + (core-files nil)) + ;; we look at each file or files in folder and add them + ;; to core-files if they are in the excludes + (cl-labels ((process-item (item) + (unless (member item excludes) + (if (file-directory-p item) + (dolist (file (directory-files item nil directory-files-no-dot-files-regexp)) + (process-item (concat item file))) + (push item core-files))))) + (dolist (item file-patterns) + (process-item item))) + core-files))) + (defun elpaa--get-devel-version (dir pkg-spec) "Compute the date-based pseudo-version used for devel builds." - (let* ((ftn (file-truename ;; Follow symlinks! - (expand-file-name (elpaa--main-file pkg-spec) dir))) - (default-directory (file-name-directory ftn)) - (gitdate + (let* ((gitdate (with-temp-buffer - (if (plist-get (cdr pkg-spec) :core) - ;; For core packages, don't use the date of the last - ;; commit to the branch, but that of the last commit - ;; to the main file. - (elpaa--call t "git" "log" "--pretty=format:%cI" "--no-patch" - "-1" "--" (file-name-nondirectory ftn)) - (elpaa--call t "git" "show" "--pretty=format:%cI" "--no-patch")) + (if (plist-get (cdr pkg-spec) :core) + (let + ((core-files (elpaa--core-files pkg-spec)) + (default-directory (expand-file-name "emacs"))) + ;; For core packages, don't use the date of the last + ;; commit to the branch, but that of the last commit + ;; to the core files. + (apply 'elpaa--call t "git" "log" "--pretty=format:%cI" "--no-patch" + "-1" "--" core-files)) + (let* ((ftn (file-truename ;; Follow symlinks! + (expand-file-name (elpaa--main-file pkg-spec) dir))) + (default-directory (file-name-directory ftn))) + (elpaa--call t "git" "show" "--pretty=format:%cI" "--no-patch"))) (buffer-string))) (verdate ;; Convert Git's date into something that looks like a version number. -- 2.41.0