From 8c0e08ad7d354cd9672113b05da1c95767ad288e Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Thu, 31 Oct 2019 16:54:29 +0100 Subject: [PATCH] update ghub --- elpa/ghub-20190121.2116/ghub-autoloads.el | 90 ----------- .../buck.el | 0 .../dir | 0 elpa/ghub-20191007.1420/ghub-autoloads.el | 51 ++++++ .../ghub-graphql.el | 153 +++++++++--------- .../ghub-pkg.el | 3 +- .../ghub.el | 120 ++++++++++---- .../ghub.info | 38 +++-- .../glab.el | 0 .../gogs.el | 0 elpa/ghub-20191007.1420/gsexp.el | 94 +++++++++++ .../gtea.el | 0 12 files changed, 326 insertions(+), 223 deletions(-) delete mode 100644 elpa/ghub-20190121.2116/ghub-autoloads.el rename elpa/{ghub-20190121.2116 => ghub-20191007.1420}/buck.el (100%) rename elpa/{ghub-20190121.2116 => ghub-20191007.1420}/dir (100%) create mode 100644 elpa/ghub-20191007.1420/ghub-autoloads.el rename elpa/{ghub-20190121.2116 => ghub-20191007.1420}/ghub-graphql.el (79%) rename elpa/{ghub-20190121.2116 => ghub-20191007.1420}/ghub-pkg.el (65%) rename elpa/{ghub-20190121.2116 => ghub-20191007.1420}/ghub.el (90%) rename elpa/{ghub-20190121.2116 => ghub-20191007.1420}/ghub.info (98%) rename elpa/{ghub-20190121.2116 => ghub-20191007.1420}/glab.el (100%) rename elpa/{ghub-20190121.2116 => ghub-20191007.1420}/gogs.el (100%) create mode 100644 elpa/ghub-20191007.1420/gsexp.el rename elpa/{ghub-20190121.2116 => ghub-20191007.1420}/gtea.el (100%) diff --git a/elpa/ghub-20190121.2116/ghub-autoloads.el b/elpa/ghub-20190121.2116/ghub-autoloads.el deleted file mode 100644 index 2785cba7..00000000 --- a/elpa/ghub-20190121.2116/ghub-autoloads.el +++ /dev/null @@ -1,90 +0,0 @@ -;;; ghub-autoloads.el --- automatically extracted autoloads -;; -;;; Code: - -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) - - -;;;### (autoloads nil "buck" "buck.el" (0 0 0 0)) -;;; Generated autoloads from buck.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "buck" '("buck-default-host"))) - -;;;*** - -;;;### (autoloads nil "ghub" "ghub.el" (0 0 0 0)) -;;; Generated autoloads from ghub.el - -(autoload 'ghub-create-token "ghub" "\ -Create, store and return a new token. - -HOST is the Github instance, usually \"api.github.com\". -USERNAME is the name of a user on that instance. -PACKAGE is the package that will use the token. -SCOPES are the scopes the token is given access to. - -\(fn HOST USERNAME PACKAGE SCOPES)" t nil) - -(autoload 'ghub-token-scopes "ghub" "\ -Return and echo the scopes of the specified token. -This is intended for debugging purposes only. The user -has to provide several values including their password. - -\(fn HOST USERNAME PACKAGE)" t nil) - -(autoload 'ghub-clear-caches "ghub" "\ -Clear all caches that might negatively affect Ghub. - -If a library that is used by Ghub caches incorrect information -such as a mistyped password, then that can prevent Ghub from -asking the user for the correct information again. - -Set `url-http-real-basic-auth-storage' to nil -and call `auth-source-forget+'. - -\(fn)" t nil) - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ghub" '("auth-source-netrc-parse-next-interesting@save-match-data" "ghub-"))) - -;;;*** - -;;;### (autoloads nil "ghub-graphql" "ghub-graphql.el" (0 0 0 0)) -;;; Generated autoloads from ghub-graphql.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ghub-graphql" '("ghub-"))) - -;;;*** - -;;;### (autoloads nil "glab" "glab.el" (0 0 0 0)) -;;; Generated autoloads from glab.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "glab" '("glab-default-host"))) - -;;;*** - -;;;### (autoloads nil "gogs" "gogs.el" (0 0 0 0)) -;;; Generated autoloads from gogs.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "gogs" '("gogs-default-host"))) - -;;;*** - -;;;### (autoloads nil "gtea" "gtea.el" (0 0 0 0)) -;;; Generated autoloads from gtea.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "gtea" '("gtea-default-host"))) - -;;;*** - -;;;### (autoloads nil nil ("ghub-pkg.el") (0 0 0 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; ghub-autoloads.el ends here diff --git a/elpa/ghub-20190121.2116/buck.el b/elpa/ghub-20191007.1420/buck.el similarity index 100% rename from elpa/ghub-20190121.2116/buck.el rename to elpa/ghub-20191007.1420/buck.el diff --git a/elpa/ghub-20190121.2116/dir b/elpa/ghub-20191007.1420/dir similarity index 100% rename from elpa/ghub-20190121.2116/dir rename to elpa/ghub-20191007.1420/dir diff --git a/elpa/ghub-20191007.1420/ghub-autoloads.el b/elpa/ghub-20191007.1420/ghub-autoloads.el new file mode 100644 index 00000000..f87340ca --- /dev/null +++ b/elpa/ghub-20191007.1420/ghub-autoloads.el @@ -0,0 +1,51 @@ +;;; ghub-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) + +;;;### (autoloads nil "ghub" "ghub.el" (23994 46481 891444 634000)) +;;; Generated autoloads from ghub.el + +(autoload 'ghub-create-token "ghub" "\ +Create, store and return a new token. + +HOST is the Github instance, usually \"api.github.com\". +USERNAME is the name of a user on that instance. +PACKAGE is the package that will use the token. +SCOPES are the scopes the token is given access to. + +\(fn HOST USERNAME PACKAGE SCOPES)" t nil) + +(autoload 'ghub-token-scopes "ghub" "\ +Return and echo the scopes of the specified token. +This is intended for debugging purposes only. The user +has to provide several values including their password. + +\(fn HOST USERNAME PACKAGE)" t nil) + +(autoload 'ghub-clear-caches "ghub" "\ +Clear all caches that might negatively affect Ghub. + +If a library that is used by Ghub caches incorrect information +such as a mistyped password, then that can prevent Ghub from +asking the user for the correct information again. + +Set `url-http-real-basic-auth-storage' to nil +and call `auth-source-forget+'. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil nil ("buck.el" "ghub-graphql.el" "ghub-pkg.el" +;;;;;; "glab.el" "gogs.el" "gsexp.el" "gtea.el") (23994 46481 895331 +;;;;;; 836000)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; ghub-autoloads.el ends here diff --git a/elpa/ghub-20190121.2116/ghub-graphql.el b/elpa/ghub-20191007.1420/ghub-graphql.el similarity index 79% rename from elpa/ghub-20190121.2116/ghub-graphql.el rename to elpa/ghub-20191007.1420/ghub-graphql.el index 53133e75..b39f1bc3 100644 --- a/elpa/ghub-20190121.2116/ghub-graphql.el +++ b/elpa/ghub-20191007.1420/ghub-graphql.el @@ -23,7 +23,7 @@ (require 'dash) (require 'ghub) -(require 'graphql) +(require 'gsexp) (require 'treepy) (eval-when-compile @@ -100,7 +100,7 @@ behave as for `ghub-request' (which see)." name) (issues [(:edges t) (:singular issue number) - (orderBy ((field . UPDATED_AT) (direction . DESC)))] + (orderBy ((field UPDATED_AT) (direction DESC)))] number state (author login) @@ -129,7 +129,7 @@ behave as for `ghub-request' (which see)." description) (pullRequests [(:edges t) (:singular pullRequest number) - (orderBy ((field . UPDATED_AT) (direction . DESC)))] + (orderBy ((field UPDATED_AT) (direction DESC)))] number state (author login) @@ -150,6 +150,8 @@ behave as for `ghub-request' (which see)." nameWithOwner)) (assignees [(:edges t)] id) + (reviewRequests [(:edges t)] + (requestedReviewer "... on User { id }\n")) (comments [(:edges t)] databaseId (author login) @@ -218,6 +220,7 @@ data as the only argument." (:constructor ghub--make-graphql-req) (:copier nil)) (query nil :read-only t) + (query-str nil :read-only nil) (variables nil :read-only t) (until nil :read-only t) (buffer nil :read-only t) @@ -234,7 +237,11 @@ See Info node `(ghub)GraphQL Support'." (setq username (ghub--username host forge))) (ghub--graphql-retrieve (ghub--make-graphql-req - :url (url-generic-parse-url (concat "https://" host "/graphql")) + :url (url-generic-parse-url + (format "https://%s/graphql" + (if (string-suffix-p "/v3" host) + (substring host 0 -3) + host))) :method "POST" :headers (ghub--headers nil host auth username forge) :handler 'ghub--graphql-handle-response @@ -258,13 +265,15 @@ See Info node `(ghub)GraphQL Support'." (let ((p (cl-incf (ghub--graphql-req-pages req)))) (when (> p 1) (ghub--graphql-set-mode-line req "Fetching page %s" p))) + (setf (ghub--graphql-req-query-str req) + (gsexp-encode + (ghub--graphql-prepare-query + (ghub--graphql-req-query req) + lineage cursor))) (ghub--retrieve (let ((json-false nil)) (ghub--encode-payload - `((query . ,(ghub--graphql-encode - (ghub--graphql-prepare-query - (ghub--graphql-req-query req) - lineage cursor))) + `((query . ,(ghub--graphql-req-query-str req)) (variables . ,(ghub--graphql-req-variables req))))) req)) @@ -279,7 +288,7 @@ See Info node `(ghub)GraphQL Support'." (when (vectorp node) (let ((alist (cl-coerce node 'list)) vars) - (when (assq :edges alist) + (when (cadr (assq :edges alist)) (push (list 'first 100) vars) (setq loc (treepy-up loc)) (setq node (treepy-node loc)) @@ -291,9 +300,7 @@ See Info node `(ghub)GraphQL Support'." (setq loc (treepy-down loc)) (setq loc (treepy-next loc))) (dolist (elt alist) - (cond ((eq (car elt) :alias) - (push elt vars)) - ((keywordp (car elt))) + (cond ((keywordp (car elt))) ((= (length elt) 3) (push (list (nth 0 elt) (nth 1 elt)) vars) @@ -301,7 +308,7 @@ See Info node `(ghub)GraphQL Support'." (nth 2 elt)) variables)) ((= (length elt) 2) (push elt vars)))) - (setq loc (treepy-replace loc (cl-coerce vars 'vector)))))) + (setq loc (treepy-replace loc (vconcat (nreverse vars))))))) (if (treepy-end-p loc) (let ((node (copy-sequence (treepy-node loc)))) (when variables @@ -320,59 +327,56 @@ See Info node `(ghub)GraphQL Support'." (payload (ghub--handle-response-error status payload req)) (err (plist-get status :error)) (errors (cdr (assq 'errors payload))) - (errors (and errors - (cons 'ghub-graphql-error errors))) - (data (assq 'data payload)) - (value (ghub--req-value req))) - (setf (ghub--req-value req) value) + (errors (and errors (cons 'ghub-graphql-error errors)))) (if (or err errors) (if-let ((errorback (ghub--req-errorback req))) (funcall errorback (or err errors) headers status req) (ghub--signal-error (or err errors))) - (ghub--graphql-walk-response value data req)))) + (ghub--graphql-walk-response req (assq 'data payload))))) (when (buffer-live-p buffer) (kill-buffer buffer))))) -(defun ghub--graphql-walk-response (loc data req) - (if (not loc) - (setf (ghub--req-value req) - (setq loc (ghub--alist-zip data))) - (setq data (ghub--graphql-narrow-data data (ghub--graphql-lineage loc))) - (setf (alist-get 'edges data) - (append (alist-get 'edges (treepy-node loc)) - (or (alist-get 'edges data) - (error "BUG: Expected new nodes")))) - (setq loc (treepy-replace loc data))) - (cl-block nil - (while t - (when (eq (car-safe (treepy-node loc)) 'edges) - (setq loc (treepy-up loc)) - (pcase-let ((`(,key . ,val) (treepy-node loc))) - (let-alist val - (let* ((cursor (and .pageInfo.hasNextPage - .pageInfo.endCursor)) - (until (cdr (assq (intern (format "%s-until" key)) - (ghub--graphql-req-until req)))) - (nodes (mapcar #'cdar .edges)) - (nodes (if until - (--take-while - (or (string> (cdr (assq 'updatedAt it)) until) - (setq cursor nil)) - nodes) - nodes))) - (if cursor - (progn - (setf (ghub--req-value req) loc) - (ghub--graphql-retrieve req - (ghub--graphql-lineage loc) - cursor) - (cl-return)) - (setq loc (treepy-replace loc (cons key nodes)))))))) - (if (not (treepy-end-p loc)) - (setq loc (treepy-next loc)) - (funcall (ghub--req-callback req) - (treepy-root loc)) - (cl-return))))) +(defun ghub--graphql-walk-response (req data) + (let* ((loc (ghub--req-value req)) + (loc (if (not loc) + (ghub--alist-zip data) + (setq data (ghub--graphql-narrow-data + data (ghub--graphql-lineage loc))) + (setf (alist-get 'edges data) + (append (alist-get 'edges (treepy-node loc)) + (or (alist-get 'edges data) + (error "BUG: Expected new nodes")))) + (treepy-replace loc data)))) + (cl-block nil + (while t + (when (eq (car-safe (treepy-node loc)) 'edges) + (setq loc (treepy-up loc)) + (pcase-let ((`(,key . ,val) (treepy-node loc))) + (let-alist val + (let* ((cursor (and .pageInfo.hasNextPage + .pageInfo.endCursor)) + (until (cdr (assq (intern (format "%s-until" key)) + (ghub--graphql-req-until req)))) + (nodes (mapcar #'cdar .edges)) + (nodes (if until + (--take-while + (or (string> (cdr (assq 'updatedAt it)) until) + (setq cursor nil)) + nodes) + nodes))) + (if cursor + (progn + (setf (ghub--req-value req) loc) + (ghub--graphql-retrieve req + (ghub--graphql-lineage loc) + cursor) + (cl-return)) + (setq loc (treepy-replace loc (cons key nodes)))))))) + (if (not (treepy-end-p loc)) + (setq loc (treepy-next loc)) + (funcall (ghub--req-callback req) + (treepy-root loc)) + (cl-return)))))) (defun ghub--graphql-lineage (loc) (let (lineage) @@ -399,8 +403,14 @@ See Info node `(ghub)GraphQL Support'." ,(vector (list (cadr single) (cdr (car lineage)))) ,@(if (cdr lineage) (ghub--graphql-narrow-query child (cdr lineage) cursor) - child))) + child))) (let* ((child (or (assq (car lineage) (cdr query)) + ;; Alias + (cl-find-if (lambda (c) + (eq (car-safe (car-safe c)) + (car lineage))) + query) + ;; Edges (cl-find-if (lambda (c) (and (listp c) (vectorp (cadr c)) @@ -408,7 +418,8 @@ See Info node `(ghub)GraphQL Support'." (cl-coerce (cadr c) 'list))) (car lineage)))) - (cdr query)))) + (cdr query)) + (error "BUG: Failed to narrow query"))) (object (car query)) (args (and (vectorp (cadr query)) (cadr query)))) @@ -424,26 +435,6 @@ See Info node `(ghub)GraphQL Support'." (t child)))))) -(defun ghub--graphql-encode (g) - (if (symbolp g) - (symbol-name g) - (let* ((object (graphql--encode-object (car g))) - (args (and (vectorp (cadr g)) - (cl-coerce (cadr g) 'list))) - (aliasp (cadr (assq :alias args))) - (fields (if args (cddr g) (cdr g))) - (fields (and fields - (mapconcat #'ghub--graphql-encode fields "\n"))) - (args (and args - (mapconcat (pcase-lambda (`(,key ,val)) - (graphql--encode-argument key val)) - args ",\n")))) - (if aliasp - (concat object ": " fields) - (concat object - (and args (format " (\n%s)" args)) - (and fields (format " {\n%s\n}" fields))))))) - (defun ghub--alist-zip (root) (let ((branchp (lambda (elt) (and (listp elt) (listp (cdr elt))))) (make-node (lambda (_ children) children))) diff --git a/elpa/ghub-20190121.2116/ghub-pkg.el b/elpa/ghub-20191007.1420/ghub-pkg.el similarity index 65% rename from elpa/ghub-20190121.2116/ghub-pkg.el rename to elpa/ghub-20191007.1420/ghub-pkg.el index 64348b9c..2cfdd4b5 100644 --- a/elpa/ghub-20190121.2116/ghub-pkg.el +++ b/elpa/ghub-20191007.1420/ghub-pkg.el @@ -1,7 +1,6 @@ -(define-package "ghub" "20190121.2116" "Minuscule client libraries for Git forge APIs." +(define-package "ghub" "20191007.1420" "Minuscule client libraries for Git forge APIs." '((emacs "25.1") (dash "2.14.1") - (graphql "0.1.1") (let-alist "1.0.5") (treepy "0.1.1"))) ;; Local Variables: diff --git a/elpa/ghub-20190121.2116/ghub.el b/elpa/ghub-20191007.1420/ghub.el similarity index 90% rename from elpa/ghub-20190121.2116/ghub.el rename to elpa/ghub-20191007.1420/ghub.el index bdf4ae8b..ec73de58 100644 --- a/elpa/ghub-20190121.2116/ghub.el +++ b/elpa/ghub-20191007.1420/ghub.el @@ -51,6 +51,7 @@ (require 'auth-source) (require 'cl-lib) +(require 'gnutls) (require 'json) (require 'let-alist) (require 'url) @@ -95,6 +96,9 @@ at URL `https://github.com/settings/tokens'.") If this is nil, then the value returned by `system-name' is used instead.") +(defvar ghub-insecure-hosts nil + "List of hosts that use http instead of https.") + ;;; Request ;;;; Object @@ -337,7 +341,12 @@ Both callbacks are called with four arguments. (ghub--encode-payload payload) (ghub--make-req :url (url-generic-parse-url - (concat "https://" host resource + (concat (if (member host ghub-insecure-hosts) "http://" "https://") + (if (and (equal resource "/graphql") + (string-suffix-p "/v3" host)) + (substring host 0 -3) + host) + resource (and query (concat "?" (ghub--url-encode-params query))))) :forge forge :silent silent @@ -431,18 +440,46 @@ this function is called with nil for PAYLOAD." (cl-defun ghub-repository-id (owner name &key username auth host forge noerror) "Return the id of the specified repository. Signal an error if the id cannot be determined." - (let ((fn (intern (format "%s-repository-id" (or forge 'ghub))))) - (or (funcall (if (eq fn 'ghub-repository-id) 'ghub--repository-id fn) - owner name :username username :auth auth :host host) + (let ((fn (cl-case forge + ((nil ghub github) 'ghub--repository-id) + (gitlab 'glab-repository-id) + (gittea 'gtea-repository-id) + (gogs 'gogs-repository-id) + (bitbucket 'buck-repository-id) + (t (intern (format "%s-repository-id" forge)))))) + (unless (fboundp fn) + (error "ghub-repository-id: Forge type/abbreviation `%s' is unknown" + forge)) + (or (funcall fn owner name :username username :auth auth :host host) (and (not noerror) (error "Repository %S does not exist on %S.\n%s%S?" (concat owner "/" name) - (or host (ghub--host host)) + (or host (ghub--host forge)) "Maybe it was renamed and you have to update " "remote..url"))))) ;;;; Internal +(defvar ghub-use-workaround-for-emacs-bug + (and + ;; Note: For build sans gnutls, `libgnutls-version' is -1. + (>= libgnutls-version 30603) + (version<= emacs-version "26.2") + 'force) + "Whether to use a kludge that hopefully works around an Emacs bug. + +In Emacs versions before 26.3 there is a bug that causes network +connections to fail when using TLS1.3. If this variable is +non-nil, then Ghub works around that by binding +`gnutls-algorithm-priority' to \"NORMAL:-VERS-TLS1.3\", unless we +think it is unnecessary. If `force' then always use the +workaround. Currently the latter is the default except when +using Emacs 26.3+, or the libgnutls is earlier than 3.6.3 (when +it introduced TLS1.3). + +For more information see https://github.com/magit/ghub/issues/81 +and https://debbugs.gnu.org/cgi/bugreport.cgi?bug=34341.") + (cl-defun ghub--retrieve (payload req) (let ((url-request-extra-headers (let ((headers (ghub--req-headers req))) @@ -452,7 +489,16 @@ Signal an error if the id cannot be determined." (url-show-status nil) (url (ghub--req-url req)) (handler (ghub--req-handler req)) - (silent (ghub--req-silent req))) + (silent (ghub--req-silent req)) + (gnutls-algorithm-priority + (if (and ghub-use-workaround-for-emacs-bug + (or (eq ghub-use-workaround-for-emacs-bug 'force) + (and (not gnutls-algorithm-priority) + (>= libgnutls-version 30603) + (version<= emacs-version "26.2") + (memq (ghub--req-forge req) '(github nil))))) + "NORMAL:-VERS-TLS1.3" + gnutls-algorithm-priority))) (if (or (ghub--req-callback req) (ghub--req-errorback req)) (url-retrieve url handler (list req) silent) @@ -518,15 +564,10 @@ Signal an error if the id cannot be determined." See https://github.com/magit/ghub/issues/81. headers: %S status: %S - buffer: %S - buffer-string: - %S - --- end of buffer-string ---" + buffer: %S" url-http-end-of-headers status - (current-buffer) - (buffer-substring-no-properties - (point-min) (point-max))))) + (current-buffer)))) (while (re-search-forward "^\\([^:]*\\): \\(.+\\)" url-http-end-of-headers t) (push (cons (match-string 1) @@ -717,7 +758,7 @@ and call `auth-source-forget+'." (defun ghub--auth (host auth &optional username forge) (unless username - (setq username (ghub--username host))) + (setq username (ghub--username host forge))) (if (eq auth 'basic) (cl-ecase forge ((nil github gitea gogs bitbucket) @@ -729,19 +770,32 @@ and call `auth-source-forget+'." "Authorization") (gitlab "Private-Token")) - (concat - (and (not (eq forge 'gitlab)) "token ") - (encode-coding-string - (cl-typecase auth - (string auth) - (null (ghub--token host username 'ghub nil forge)) - (symbol (ghub--token host username auth nil forge)) - (t (signal 'wrong-type-argument - `((or stringp symbolp) ,auth)))) - 'utf-8))))) + (if (eq forge 'bitbucket) + ;; For some undocumented reason Bitbucket supports + ;; values of the form "token " only for GET + ;; requests. For PUT requests we have to use basic + ;; authentication. Note that the secret is a token + ;; (aka "app password"), not the actual password. + ;; The documentation fails to mention this little + ;; detail. See #97. + (concat "Basic " + (base64-encode-string + (concat username ":" + (ghub--token host username auth nil forge)))) + (concat + (and (not (eq forge 'gitlab)) "token ") + (encode-coding-string + (cl-typecase auth + (string auth) + (null (ghub--token host username 'ghub nil forge)) + (symbol (ghub--token host username auth nil forge)) + (t (signal 'wrong-type-argument + `((or stringp symbolp) ,auth)))) + 'utf-8)))))) (defun ghub--basic-auth (host username) - (let ((url (url-generic-parse-url (concat "https://" host)))) + (let ((url (url-generic-parse-url + (if (member host ghub-insecure-hosts) "http://" "https://")))) (setf (url-user url) username) (url-basic-auth url t))) @@ -792,7 +846,7 @@ See https://magit.vc/manual/ghub/Support-for-Other-Forges.html for instructions. user host)))))))) (if (functionp token) (funcall token) token))) -(defun ghub--host (&optional forge) +(cl-defmethod ghub--host (forge) (cl-ecase forge ((nil github) (or (ignore-errors (car (process-lines "git" "config" "github.host"))) @@ -810,7 +864,7 @@ See https://magit.vc/manual/ghub/Support-for-Other-Forges.html for instructions. (or (ignore-errors (car (process-lines "git" "config" "bitbucket.host"))) (bound-and-true-p buck-default-host))))) -(defun ghub--username (host &optional forge) +(cl-defmethod ghub--username (host &optional forge) (let ((var (cl-ecase forge ((nil github) @@ -838,10 +892,10 @@ See https://magit.vc/manual/ghub/Support-for-Other-Forges.html for instructions. (error (let ((user (read-string (format "Git variable `%s' is unset. Set to: " var)))) - (or (and user (progn (call-process "git" nil nil nil - "config" "--global" var user) - user)) - (user-error "Abort"))))))) + (if (equal user "") + (user-error "The empty string is not a valid username") + (call-process "git" nil nil nil "config" "--global" var user) + user)))))) (defun ghub--ident (username package) (format "%s^%s" username package)) @@ -954,7 +1008,7 @@ Please visit https://github.com/settings/tokens and delete it." ident) (defvar ghub--2fa-cache nil) (defun ghub--read-2fa-code () - (let ((code (read-number "Two-factor authentication code: " + (let ((code (read-string "Two-factor authentication code: " (and ghub--2fa-cache (< (float-time (time-subtract (current-time) @@ -962,7 +1016,7 @@ Please visit https://github.com/settings/tokens and delete it." ident) 25) (car ghub--2fa-cache))))) (setq ghub--2fa-cache (cons code (current-time))) - (number-to-string code))) + code)) (defun ghub--auth-source-get (keys &rest spec) (declare (indent 1)) diff --git a/elpa/ghub-20190121.2116/ghub.info b/elpa/ghub-20191007.1420/ghub.info similarity index 98% rename from elpa/ghub-20190121.2116/ghub.info rename to elpa/ghub-20191007.1420/ghub.info index a54177bb..5d0bdb48 100644 --- a/elpa/ghub-20190121.2116/ghub.info +++ b/elpa/ghub-20191007.1420/ghub.info @@ -46,7 +46,7 @@ adoption would make life easier for users and maintainers alike, because then all packages that talk to forge APIs could be configured the same way. -This manual is for Ghub version 3.2.0 (v3.2.0-1-gae7acf4+1). +This manual is for Ghub version 3.2.0 (v3.2.0-35-g9d75d30+1). Copyright (C) 2017-2019 Jonas Bernoulli @@ -193,6 +193,10 @@ this should be true even when configuring the very first token. ‘github.git.example.com/api/v3.user’ to ‘jtribbiani’. The latter is necessary even if your username on Github.com is the same. + For some Github Enterprice instances ‘/api’ has to be used instead + of ‘/api/v3’ as shown above. If the wizard fails in both cases, + then try creating the token manually. + • If the variable ‘github.user’ (or ‘github.HOST.user’ for an Enterprise instance) is unset when the wizard is first summoned, then you are asked to provide your username. That value is then @@ -1290,22 +1294,22 @@ File: ghub.info, Node: Forge Limitations and Notes, Prev: Forge Functions and  Tag Table: Node: Top764 -Node: Introduction3279 -Node: Getting Started6321 -Node: Setting the Username10055 -Node: Interactively Creating and Storing a Token11480 -Node: Manually Creating and Storing a Token17131 -Node: How Ghub uses Auth-Source18356 -Node: Using Ghub in Personal Scripts20289 -Node: Using Ghub in a Package21745 -Node: API24363 -Node: Making Requests25160 -Node: Authentication39259 -Node: Configuration Variables41104 -Node: GraphQL Support44824 -Node: Support for Other Forges51489 -Node: Forge Functions and Variables51706 -Node: Forge Limitations and Notes56225 +Node: Introduction3280 +Node: Getting Started6322 +Node: Setting the Username10250 +Node: Interactively Creating and Storing a Token11675 +Node: Manually Creating and Storing a Token17326 +Node: How Ghub uses Auth-Source18551 +Node: Using Ghub in Personal Scripts20484 +Node: Using Ghub in a Package21940 +Node: API24558 +Node: Making Requests25355 +Node: Authentication39454 +Node: Configuration Variables41299 +Node: GraphQL Support45019 +Node: Support for Other Forges51684 +Node: Forge Functions and Variables51901 +Node: Forge Limitations and Notes56420  End Tag Table diff --git a/elpa/ghub-20190121.2116/glab.el b/elpa/ghub-20191007.1420/glab.el similarity index 100% rename from elpa/ghub-20190121.2116/glab.el rename to elpa/ghub-20191007.1420/glab.el diff --git a/elpa/ghub-20190121.2116/gogs.el b/elpa/ghub-20191007.1420/gogs.el similarity index 100% rename from elpa/ghub-20190121.2116/gogs.el rename to elpa/ghub-20191007.1420/gogs.el diff --git a/elpa/ghub-20191007.1420/gsexp.el b/elpa/ghub-20191007.1420/gsexp.el new file mode 100644 index 00000000..ced9dcfd --- /dev/null +++ b/elpa/ghub-20191007.1420/gsexp.el @@ -0,0 +1,94 @@ +;;; gsexp.el --- GraphQl as S-expressions -*- lexical-binding: t -*- + +;; Copyright (C) 2016-2019 Jonas Bernoulli + +;; Author: Jonas Bernoulli +;; Homepage: https://github.com/magit/ghub +;; Keywords: tools + +;; This file is not part of GNU Emacs. + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; For a copy of the GPL see https://www.gnu.org/licenses/gpl.txt. + +;;; Commentary: + +;; This library encodes S-expressions as GraphQl documents. Currently +;; it is rather incomplete and only intended for use by `ghub-graphql' +;; but I might fill the gaps and add documentation eventually. I am +;; not in a hurry though. + +;;; Code: + +(require 'cl-lib) + +(defun gsexp-encode (document) + (gsexp--pp (gsexp--encode-field document))) + +(defun gsexp--encode-field (field) + (cond + ((stringp field) + field) + ((symbolp field) + (symbol-name field)) + ((listp (car field)) + (concat (format "%s: " (caar field)) + (gsexp--encode-field (cons (cadar field) + (cdr field))))) + (t + (concat (symbol-name (pop field)) + (and (vectorp (car field)) + (format " (\n%s)" + (mapconcat #'gsexp--encode-argument + (append (pop field) nil) + ",\n"))) + (and field + (format " {\n%s\n}" + (mapconcat #'gsexp--encode-field field "\n"))))))) + +(cl-defun gsexp--encode-argument ((argument value)) + (format "%s: %s" argument (gsexp--encode-value value))) + +(defun gsexp--encode-value (value) + (cond + ((numberp value) + (number-to-string value)) + ((symbolp value) ; including variables, enums, booleans and null + (symbol-name value)) + ((stringp value) + (prin1-to-string value)) + ((vectorp value) + (format "(%s)" (mapconcat #'gsexp--encode-value value ""))) + ((listp value) + (format "{%s}" (mapconcat + (pcase-lambda (`(,name ,value)) + (format "%s: %s" name (gsexp--encode-value value))) + value ", "))) + (t (error "Invalid field value: %S" value)))) + +(defun gsexp--pp (string) + (with-temp-buffer + (save-excursion + (insert string)) + (while (< (point) (point-max)) + (unless (and (bolp) (eolp)) + (save-excursion + (let ((level (car (syntax-ppss (point-at-bol))))) + (when (looking-at "\\s-*\\s)") + (cl-decf level)) + (indent-line-to (* 2 level))))) + (forward-line 1)) + (buffer-string))) + +;;; _ +(provide 'gsexp) +;;; gsexp.el ends here diff --git a/elpa/ghub-20190121.2116/gtea.el b/elpa/ghub-20191007.1420/gtea.el similarity index 100% rename from elpa/ghub-20190121.2116/gtea.el rename to elpa/ghub-20191007.1420/gtea.el -- 2.47.3