From 5feea2e7f097d83c6e55493e3fe23c896487c26f Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 14 Oct 2016 12:04:53 +0200 Subject: [PATCH] Update magithub --- .../magithub-autoloads.el | 2 +- .../magithub-cache.el | 0 .../magithub-ci.el | 86 +++++++++++-------- .../magithub-core.el | 31 ++++++- .../magithub-issue.el | 10 ++- .../magithub-pkg.el | 2 +- .../magithub.el | 0 7 files changed, 89 insertions(+), 42 deletions(-) rename elpa/{magithub-20161013.2008 => magithub-20161013.2332}/magithub-autoloads.el (94%) rename elpa/{magithub-20161013.2008 => magithub-20161013.2332}/magithub-cache.el (100%) rename elpa/{magithub-20161013.2008 => magithub-20161013.2332}/magithub-ci.el (77%) rename elpa/{magithub-20161013.2008 => magithub-20161013.2332}/magithub-core.el (88%) rename elpa/{magithub-20161013.2008 => magithub-20161013.2332}/magithub-issue.el (96%) rename elpa/{magithub-20161013.2008 => magithub-20161013.2332}/magithub-pkg.el (80%) rename elpa/{magithub-20161013.2008 => magithub-20161013.2332}/magithub.el (100%) diff --git a/elpa/magithub-20161013.2008/magithub-autoloads.el b/elpa/magithub-20161013.2332/magithub-autoloads.el similarity index 94% rename from elpa/magithub-20161013.2008/magithub-autoloads.el rename to elpa/magithub-20161013.2332/magithub-autoloads.el index d2cfca1..fbcf753 100644 --- a/elpa/magithub-20161013.2008/magithub-autoloads.el +++ b/elpa/magithub-20161013.2332/magithub-autoloads.el @@ -5,7 +5,7 @@ ;;;### (autoloads nil nil ("magithub-cache.el" "magithub-ci.el" "magithub-core.el" ;;;;;; "magithub-issue.el" "magithub-pkg.el" "magithub.el") (22528 -;;;;;; 31239 328273 102000)) +;;;;;; 44286 378835 655000)) ;;;*** diff --git a/elpa/magithub-20161013.2008/magithub-cache.el b/elpa/magithub-20161013.2332/magithub-cache.el similarity index 100% rename from elpa/magithub-20161013.2008/magithub-cache.el rename to elpa/magithub-20161013.2332/magithub-cache.el diff --git a/elpa/magithub-20161013.2008/magithub-ci.el b/elpa/magithub-20161013.2332/magithub-ci.el similarity index 77% rename from elpa/magithub-20161013.2008/magithub-ci.el rename to elpa/magithub-20161013.2332/magithub-ci.el index 3153c83..6c23d7a 100644 --- a/elpa/magithub-20161013.2008/magithub-ci.el +++ b/elpa/magithub-20161013.2332/magithub-ci.el @@ -79,14 +79,12 @@ If magithub.ci.enabled is not set, CI is considered to be enabled." (defun magithub-ci-status () "One of 'success, 'error, 'failure, 'pending, or 'no-status." - (let ((same-commit - (string-equal (magit-rev-parse "HEAD") - (magithub-ci-status-current-commit)))) - (unless same-commit - (magithub-cache-clear (magithub-repo-id) :ci-status)) - (if (eq (magithub-cache-value (magithub-repo-id) :ci-status) - 'success) - 'success + (unless (string-equal (magit-rev-parse "HEAD") + (magithub-ci-status-current-commit)) + (magithub-cache-clear (magithub-repo-id) :ci-status)) + (let ((cached-val (magithub-cache-value (magithub-repo-id) :ci-status))) + (if (and (consp cached-val) (eq (plist-get (car cached-val) :status) 'success)) + cached-val (magithub-cache (magithub-repo-id) :ci-status '(magithub-ci-status--internal))))) @@ -96,42 +94,32 @@ If magithub.ci.enabled is not set, CI is considered to be enabled." (if new-value (apply #'magit-set new-value keys) (apply #'magit-get keys)))) -(defun magithub-ci-update-urls (statuses) - "Updates `magithub-ci-urls' according to STATUSES. -See also `magithub-repo-id'." - (let* ((id (magithub-repo-id)) - (repo-urls (assoc id magithub-ci-urls)) - (urls (mapcar (lambda (s) (plist-get s :url)) statuses))) - (if repo-urls (setcdr repo-urls urls) - (add-to-list 'magithub-ci-urls (cons id urls)) - urls))) - (defun magithub-ci-status--parse-2.2.8 (output) "Backwards compatibility for old versions of hub. See `magithub-ci-status--parse'." (-when-let (matches (cdr (s-match (rx bos (group (+ (any alpha space))) (? ": " (group (+ (not (any " "))))) eos) output))) - (let ((status (list :status (intern (replace-regexp-in-string "\s" "-" (car matches))) - :url (cadr matches)))) - (magithub-ci-update-urls (list status)) - status))) + (list (list :status (intern (replace-regexp-in-string + "\s" "-" (car matches))) + :url (cadr matches))))) (defun magithub-ci-status--internal (&optional for-commit) "One of 'success, 'error, 'failure, 'pending, or 'no-status." (let* ((current-commit (magit-rev-parse "HEAD")) (last-commit (or for-commit current-commit)) (output (magithub--command-output "ci-status" `("-v" ,last-commit)))) - (-if-let (check (if (magithub-hub-version-at-least "2.3") - (car (magithub-ci-status--parse output)) - (magithub-ci-status--parse-2.2.8 (car output)))) - (prog1 (or (plist-get check :status) 'no-status) - (if (not (or for-commit (plist-get check :status))) - (let ((last-commit (magithub-ci-status--last-commit))) - (unless (string-equal current-commit last-commit) - (magithub-ci-status--internal last-commit)) - (magithub-ci-status-current-commit current-commit)) - (magithub-ci-status-current-commit current-commit))) + (-if-let (checks (if (magithub-hub-version-at-least "2.3") + (magithub-ci-status--parse output) + (magithub-ci-status--parse-2.2.8 (car output)))) + (let ((overall-status (car checks))) + (prog1 (or (and (plist-get overall-status :status) checks) 'no-status) + (if (not (or for-commit (plist-get overall-status :status))) + (let ((last-commit (magithub-ci-status--last-commit))) + (unless (string-equal current-commit last-commit) + (magithub-ci-status--internal last-commit)) + (magithub-ci-status-current-commit current-commit)) + (magithub-ci-status-current-commit current-commit)))) (beep) (setq magithub-hub-error (message @@ -145,7 +133,6 @@ See `magithub-ci-status--parse'." The first status will be an `overall' status." (let ((statuses (mapcar #'magithub-ci-status--parse-line output)) (get-status (lambda (status) (lambda (s) (eq (plist-get s :status) status))))) - (magithub-ci-update-urls statuses) (cons (list :check 'overall :status @@ -236,9 +223,23 @@ See the following resources: "Browse the CI. Sets up magithub.ci.url if necessary." (interactive) - (let* ((urls (cdr (assoc (magithub-repo-id) magithub-ci-urls))) - (target-url (if (= 1 (length urls)) (car urls) - (when urls (completing-read "CI Dashboard URL: " urls))))) + (let* ((checks (magithub-ci-status)) + (checks-alist + (magithub--zip + checks + (if (magithub-hub-version-at-least "2.3") + (lambda (c) + (format "%S: %s" + (plist-get c :status) + (plist-get c :check))) + :status) + :url)) + (target-url + (if (= 1 (length checks-alist)) + (cdar checks-alist) + (when checks-alist + (cdr (assoc (completing-read "CI Service: " checks-alist) + checks-alist)))))) (when (or (null target-url) (string= "" target-url)) (user-error "No CI URL detected")) (browse-url target-url))) @@ -258,7 +259,8 @@ Sets up magithub.ci.url if necessary." (magit-refresh))) (defun magithub-insert-ci-status-header () - (let* ((status (magithub-ci-status)) + (let* ((checks (magithub-ci-status)) + (status (if (consp checks) (plist-get (car checks) :status) checks)) (face (intern (format "magithub-ci-%s" (symbol-name status)))) (status-val (cdr (assq status magithub-ci-status-alist)))) @@ -270,6 +272,16 @@ Sets up magithub.ci.url if necessary." ((functionp status-val) (funcall status-val)) (t (format "%S" status-val))) 'face (if (facep face) face 'magithub-ci-unknown))) + (when (and (consp checks) (not (eq status 'success)) (< 1 (length checks))) + (let* ((successes (-filter (lambda (c) (eq (plist-get c :status) 'success)) + checks)) + (numsuccesses (length successes)) + (numchecks (length checks))) + (insert + (format " %d succeeded; %d did not; %s for details" + numsuccesses + (- numchecks numsuccesses) + (substitute-command-keys "\\[magit-visit-thing]"))))) (insert ?\n)))) (magithub--deftoggle magithub-toggle-ci-status-header diff --git a/elpa/magithub-20161013.2008/magithub-core.el b/elpa/magithub-20161013.2332/magithub-core.el similarity index 88% rename from elpa/magithub-20161013.2008/magithub-core.el rename to elpa/magithub-20161013.2332/magithub-core.el index 3a6a2d8..d76fd3e 100644 --- a/elpa/magithub-20161013.2008/magithub-core.el +++ b/elpa/magithub-20161013.2332/magithub-core.el @@ -162,7 +162,8 @@ See /.github/ISSUE_TEMPLATE.md in this repository." "Non-nil if Magithub should do its thing." (and (executable-find magithub-hub-executable) (magithub-enabled-p) - (magithub-github-repository-p))) + (magithub-github-repository-p) + (magithub--api-available-p))) (defun magithub-error (err-message tag &optional trace) "Report a Magithub error." @@ -206,5 +207,33 @@ See /.github/ISSUE_TEMPLATE.md in this repository." (magit-refresh)) (memq ,func ,hook))) +(defun magithub--zip-case (p e) + "Get an appropriate value for element E given property/function P." + (cond + ((symbolp p) (plist-get e p)) + ((functionp p) (funcall p e)) + ((null p) e) + (t nil))) + +(defun magithub--zip (object-list prop1 prop2) + "Process OBJECT-LIST into an alist defined by PROP1 and PROP2. + +If a prop is a symbol, that property will be used. + +If a prop is a function, it will be called with the +currentelement of OBJECT-LIST. + +If a prop is nil, the entire element is used." + (delq nil + (-zip-with + (lambda (e1 e2) + (let ((p1 (magithub--zip-case prop1 e1)) + (p2 (magithub--zip-case prop2 e2))) + (unless (or (and prop1 (not p1)) + (and prop2 (not p2))) + (cons (if prop1 p1 e1) + (if prop2 p2 e2))))) + object-list object-list))) + (provide 'magithub-core) ;;; magithub-core.el ends here diff --git a/elpa/magithub-20161013.2008/magithub-issue.el b/elpa/magithub-20161013.2332/magithub-issue.el similarity index 96% rename from elpa/magithub-20161013.2008/magithub-issue.el rename to elpa/magithub-20161013.2332/magithub-issue.el index 4278382..fd8fdaa 100644 --- a/elpa/magithub-20161013.2008/magithub-issue.el +++ b/elpa/magithub-20161013.2332/magithub-issue.el @@ -282,8 +282,14 @@ default." (defun magithub-pull-request-checkout (pull-request) "Checkout PULL-REQUEST as a local branch." (interactive (list (magithub-pull-request--completing-read))) - (magithub-with-hub - (magit-checkout (plist-get pull-request :url)))) + (-when-let (url (plist-get pull-request :url)) + (magithub-with-hub + (magit-checkout url)) + (dolist (var-val `(("URL" . ,url) + ("ID" . ,(plist-get pull-request :number)))) + (magit-set (cdr var-val) + "branch" (magit-get-current-branch) + (concat "magithubPullRequest" (car var-val)))))) ;;; Hook into the status buffer (magithub--deftoggle magithub-toggle-issues diff --git a/elpa/magithub-20161013.2008/magithub-pkg.el b/elpa/magithub-20161013.2332/magithub-pkg.el similarity index 80% rename from elpa/magithub-20161013.2008/magithub-pkg.el rename to elpa/magithub-20161013.2332/magithub-pkg.el index d3e8980..580fc52 100644 --- a/elpa/magithub-20161013.2008/magithub-pkg.el +++ b/elpa/magithub-20161013.2332/magithub-pkg.el @@ -1,4 +1,4 @@ -(define-package "magithub" "20161013.2008" "Magit interfaces for GitHub" +(define-package "magithub" "20161013.2332" "Magit interfaces for GitHub" '((emacs "24.4") (magit "2.8.0") (git-commit "20160821.1338") diff --git a/elpa/magithub-20161013.2008/magithub.el b/elpa/magithub-20161013.2332/magithub.el similarity index 100% rename from elpa/magithub-20161013.2008/magithub.el rename to elpa/magithub-20161013.2332/magithub.el