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

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

[elpa] elpa-admin a5cffdb: * elpa-admin.el (elpaa--pull): Set the upstre


From: Stefan Monnier
Subject: [elpa] elpa-admin a5cffdb: * elpa-admin.el (elpaa--pull): Set the upstream branch if needed
Date: Sat, 19 Dec 2020 01:01:46 -0500 (EST)

branch: elpa-admin
commit a5cffdb4f9e802f50714cc7e847e74c3b000edad
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * elpa-admin.el (elpaa--pull): Set the upstream branch if needed
---
 elpa-admin.el | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/elpa-admin.el b/elpa-admin.el
index a88273c..bb69b16 100644
--- a/elpa-admin.el
+++ b/elpa-admin.el
@@ -988,16 +988,25 @@ Rename DIR/ to PKG-VERS/, and return the descriptor."
        ((file-directory-p ".git")
         (message "Running git pull in %S" default-directory)
         (elpaa--call t "git" "pull"))
-       ((file-exists-p ".git")
-        (if (with-temp-buffer
-              (let ((elpaa--debug nil))
-                (elpaa--call t "git" "status" "--branch" "--porcelain=2"))
-              (goto-char (point-min))
-              ;; Nothing to pull (nor push, actually).
-              (search-forward "\n# branch.ab +0 -0" nil t))
-            (elpaa--message "%s up-to-date" dirname)
-          (message "Updating worktree in %S" default-directory)
-          (elpaa--call t "git" "merge")))
+       ((file-exists-p ".git")          ;A worktree, presumably.
+        (let ((status 
+               (with-temp-buffer
+                 (let ((elpaa--debug nil))
+                   (elpaa--call t "git" "status" "--branch" "--porcelain=2"))
+                 (buffer-string))))
+          (if (string-match "\n# branch.ab +0 -0" status)
+              (elpaa--message "%s up-to-date" dirname)
+            (unless (or (string-match "\n# branch.upstream" status)
+                        (not (string-match
+                              (concat "\n# branch.head \\("
+                                      (regexp-quote elpaa--branch-prefix)
+                                      ".*\\)")
+                              status)))
+              ;; No upstream set yet.
+              (elpaa--call t "git" "branch" "--set-upstream-to"
+                           (concat "origin/" (match-string 1 status))))
+            (message "Updating worktree in %S" default-directory)
+            (elpaa--call t "git" "merge"))))
        (t (error "No .git in %S" default-directory)))
       (unless (and (eobp) (bobp))
         (message "Updated %s:%s%s" dirname



reply via email to

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