Fix +magit/clone to no longer use magithub

This commit is contained in:
Henrik Lissner 2019-02-18 18:25:57 -05:00
parent 883fcffc97
commit ecfe52f71c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 28 additions and 26 deletions

View file

@ -92,12 +92,13 @@ control in buffers."
"History for `+magit/clone' prompt.") "History for `+magit/clone' prompt.")
;;;###autoload ;;;###autoload
(defun +magit/clone (url-or-repo dir) (defun +magit/clone (url-or-repo dir)
"Delegates to `magit-clone' or `magithub-clone' depending on the repo url "Like `magit-clone', but supports additional formats on top of absolute URLs:
format."
+ USER/REPO: assumes {`+magit-default-clone-url'}/USER/REPO
+ REPO: assumes {`+magit-default-clone-url'}/{USER}/REPO, where {USER} is
ascertained from your global gitconfig."
(interactive (interactive
(progn (let* ((user (ghub--username (ghub--host)))
(require 'magithub)
(let* ((user (ghubp-username))
(repo (read-from-minibuffer (repo (read-from-minibuffer
"Clone repository (user/repo or url): " "Clone repository (user/repo or url): "
(if user (concat user "/")) (if user (concat user "/"))
@ -106,19 +107,15 @@ format."
(list repo (list repo
(read-directory-name (read-directory-name
"Destination: " "Destination: "
magithub-clone-default-directory magit-clone-default-directory
name nil name))))) name nil name))))
(require 'magithub) (magit-clone
(if (string-match "^\\([^/]+\\)/\\([^/]+\\)$" url-or-repo) (cond ((string-match-p "^[^/]+$" url-or-repo)
(let ((repo `((owner (login . ,(match-string 1 url-or-repo))) (format +magit-default-clone-url (ghub--username (ghub--host)) url-or-repo))
(name . ,(match-string 2 url-or-repo))))) ((string-match-p "^\\([^/]+\\)/\\([^/]+\\)/?$" url-or-repo)
(and (or (magithub-request (apply #'format +magit-default-clone-url (split-string url-or-repo "/" t)))
(ghubp-get-repos-owner-repo repo)) (url-or-repo))
(let-alist repo dir))
(user-error "Repository %s/%s does not exist"
.owner.login .name)))
(magithub-clone repo dir)))
(magit-clone url-or-repo dir)))
;; ;;

View file

@ -1,5 +1,10 @@
;;; tools/magit/config.el -*- lexical-binding: t; -*- ;;; tools/magit/config.el -*- lexical-binding: t; -*-
(defvar +magit-default-clone-url "https://github.com/%s/%s"
"The default location for `+magit/clone' to clone relative URLs from.
It is passed a user and repository name.")
;; ;;
;; Packages ;; Packages