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,33 +92,30 @@ control in buffers."
"History for `+magit/clone' prompt.")
;;;###autoload
(defun +magit/clone (url-or-repo dir)
"Delegates to `magit-clone' or `magithub-clone' depending on the repo url
format."
"Like `magit-clone', but supports additional formats on top of absolute URLs:
+ 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
(progn
(require 'magithub)
(let* ((user (ghubp-username))
(repo (read-from-minibuffer
"Clone repository (user/repo or url): "
(if user (concat user "/"))
nil nil '+magit-clone-history))
(name (car (last (split-string repo "/" t)))))
(list repo
(read-directory-name
"Destination: "
magithub-clone-default-directory
name nil name)))))
(require 'magithub)
(if (string-match "^\\([^/]+\\)/\\([^/]+\\)$" url-or-repo)
(let ((repo `((owner (login . ,(match-string 1 url-or-repo)))
(name . ,(match-string 2 url-or-repo)))))
(and (or (magithub-request
(ghubp-get-repos-owner-repo repo))
(let-alist repo
(user-error "Repository %s/%s does not exist"
.owner.login .name)))
(magithub-clone repo dir)))
(magit-clone url-or-repo dir)))
(let* ((user (ghub--username (ghub--host)))
(repo (read-from-minibuffer
"Clone repository (user/repo or url): "
(if user (concat user "/"))
nil nil '+magit-clone-history))
(name (car (last (split-string repo "/" t)))))
(list repo
(read-directory-name
"Destination: "
magit-clone-default-directory
name nil name))))
(magit-clone
(cond ((string-match-p "^[^/]+$" url-or-repo)
(format +magit-default-clone-url (ghub--username (ghub--host)) url-or-repo))
((string-match-p "^\\([^/]+\\)/\\([^/]+\\)/?$" url-or-repo)
(apply #'format +magit-default-clone-url (split-string url-or-repo "/" t)))
(url-or-repo))
dir))
;;

View file

@ -1,5 +1,10 @@
;;; 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