emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] master d89e32b: * admin/archive-contents.el: Add preliminary co


From: Stefan Monnier
Subject: [nongnu] master d89e32b: * admin/archive-contents.el: Add preliminary code to fetch upstream updates
Date: Thu, 26 Nov 2020 22:15:50 -0500 (EST)

branch: master
commit d89e32bbd1e8bacaa30df18b055a3bef9438c32d
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * admin/archive-contents.el: Add preliminary code to fetch upstream updates
    
    (archive--branch, archive--urtb, archive--fetch, archive--push)
    (archive--batch-fetch-and, batch-fetch-and-show, batch-fetch-and-push):
    New functions.
    
    * GNUmakefile: Add corresponding rules.
---
 GNUmakefile               | 18 ++++++++++
 admin/archive-contents.el | 86 +++++++++++++++++++++++++++++++++++++++++++++++
 externals-list            |  4 +++
 3 files changed, 108 insertions(+)

diff --git a/GNUmakefile b/GNUmakefile
index 0adf454..c6511f7 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -213,6 +213,24 @@ $(1): $(filter $(1)/%, $(elcs))
 endef
 $(foreach pkg, $(pkgs), $(eval $(call RULE-singlepkg, $(pkg))))
 
+##### Fetching updates from upstream
+
+.PHONY: fetch/%
+fetch/%:
+       $(EMACS) -l admin/archive-contents.el -f batch-fetch-and-show "$*"
+
+.PHONY: fetch-all
+fetch-all:
+       $(EMACS) -l admin/archive-contents.el -f batch-fetch-and-show "-"
+
+.PHONY: sync/%
+sync/%:
+       $(EMACS) -l admin/archive-contents.el -f batch-fetch-and-push "$*"
+
+.PHONY: sync-all
+sync-all:
+       $(EMACS) -l admin/archive-contents.el -f batch-fetch-and-push "-"
+
 
 ############### Rules to prepare the externals ################################
 
diff --git a/admin/archive-contents.el b/admin/archive-contents.el
index 48a996d..f085bf6 100644
--- a/admin/archive-contents.el
+++ b/admin/archive-contents.el
@@ -211,6 +211,17 @@ commit which modified the \"Version:\" pseudo header."
                dir pkgname 'dont-rename)))
         (archive--message "%s: %S" pkgname pkgdesc)
         (archive--update-archive-contents pkgdesc destdir)
+        (when (and nil revision-function) ;FIXME: Circumstantial evidence.
+          ;; Various problems:
+          ;; - If "make build/foo" is used by the developers in order to test
+          ;;   the build of their package, they'll end up with those spurious
+          ;;   tags which may end up spreading to unintended places.
+          ;; - The tags created in elpa.gnu.org won't spread to nongnu.git
+          ;;   because that account can't push to git.sv.gnu.org anyway.
+          (let ((default-directory (archive--dirname dir)))
+            (archive--call nil "git" "tag" "-f"
+                           (format "%s-release/%s-%s"
+                                   archive--name pkgname vers))))
         ;; FIXME: Send email announcement!
         (let ((link (expand-file-name (format "%s.tar" pkgname) destdir)))
           (when (file-exists-p link) (delete-file link))
@@ -1160,5 +1171,80 @@ If WITH-CORE is non-nil, it means we manage :core 
packages as well."
                          ""))
       (save-buffer))))
 
+;;; Fetch updates from upstream
+
+(defun archive--branch (pkg-spec)
+  (or (plist-get (cdr pkg-spec) :branch) "master"))
+
+(defun archive--urtb (pkg-spec)
+  "Return our upstream remote tracking branch for PKG-SPEC."
+  (format "refs/remotes/upstream/%s/%s" (car pkg-spec)
+          (archive--branch pkg-spec)))
+
+(defun archive--fetch (pkg-spec &optional k)
+  (let* ((pkg (car pkg-spec))
+         (url (plist-get (cdr pkg-spec) :external))
+         (branch (archive--branch pkg-spec))
+         (default-directory (archive--dirname pkg "packages"))
+         (urtb (archive--urtb pkg-spec))
+         (refspec (format "refs/heads/%s:%s"
+                          branch urtb)))
+    (if (not url)
+        (message "Missing upstream URL in externals-list for %s" pkg)
+      (message "Fetching updates for %s..." pkg)
+      (with-temp-buffer
+        (cond
+         ((not (equal 0 (archive--call t "git" "fetch" "--no-tags"
+                                       url refspec)))
+          (message "Fetch error for %s:\n%s" pkg (buffer-string)))
+         ((not (equal 0 (archive--call t "git" "log"
+                                       (format "origin/externals/%s...%s"
+                                               pkg urtb))))
+          (message "Log error for %s:\n%s" pkg (buffer-string)))
+         ((eq (point-min) (point-max))
+          (message "No pending upstream changes for %s" pkg))
+         (t (message "%s" (buffer-string))
+            (when k (funcall k pkg-spec))))))))
+
+(defun archive--push (pkg-spec)
+  (let* ((pkg (car pkg-spec))
+         (url (plist-get (cdr pkg-spec) :external))
+         (branch (archive--branch pkg-spec))
+         (urtb (archive--urtb pkg-spec)))
+    ;; FIXME: Arrange to merge if it's not a fast-forward.
+    (with-temp-buffer
+      (cond
+       ((zerop (archive--call t "git" "merge-base" "--is-ancestor"
+                              urtb (format "externals/%s" pkg)))
+        (message "Nothing to push for %s" pkg))
+       ((not (zerop (archive--call t "git" "merge-base" "--is-ancestor"
+                                   (format "externals/%s" pkg) urtb)))
+        (message "Can't push %s: not a fast-forward" pkg))
+       ((not (equal 0 (archive--call t "git" "push" "origin"
+                                     (format "%s:externals/%s" urtb pkg))))
+        (message "Fetch error for %s:\n%s" pkg (buffer-string)))
+       (t
+        (message "Pushed %s successfully:\n%s" pkg (buffer-string))
+        (let ((default-directory (expand-file-name "../../")))
+          (archive--external-package-sync pkg)))))))
+
+(defun archive--batch-fetch-and (k)
+  (let ((specs (archive--form-from-file-contents "externals-list"))
+        (pkgs command-line-args-left))
+    (setq command-line-args-left nil)
+    (if (equal pkgs '("-")) (setq pkgs (mapcar #'car specs)))
+    (dolist (pkg pkgs)
+      (let* ((pkg-spec (assoc pkg specs)))
+        (if (not pkg-spec) (message "Unknown package: %s" pkg)
+          (unless (file-directory-p (expand-file-name pkg "packages"))
+            (archive--external-package-sync pkg))
+          (archive--fetch pkg-spec k))))))
+
+(defun batch-fetch-and-show (&rest _)
+  (archive--batch-fetch-and #'ignore))
+
+(defun batch-fetch-and-push (&rest _)
+  (archive--batch-fetch-and #'archive--push))
+
 (provide 'archive-contents)
 ;;; archive-contents.el ends here
diff --git a/externals-list b/externals-list
index ba4edbf..54a8752 100644
--- a/externals-list
+++ b/externals-list
@@ -10,6 +10,10 @@
 ;; :external URL
 ;;   This specifies the location of the upstream code, usually a Git URL.
 ;;
+;; :branch BRANCH
+;;   This specified the Git branch that we follow.
+;;   By default, we follow the `master' branch.
+;;
 ;; :version-map MAP
 ;;   A list of element of the form (ORIG-VERSION REMAPPED-VERSION REVISION)
 ;;   This allows replacing the ORIG-VERSION from the <pkg>.el file



reply via email to

[Prev in Thread] Current Thread [Next in Thread]