Fix +magit/clone to no longer use magithub
This commit is contained in:
parent
883fcffc97
commit
ecfe52f71c
2 changed files with 28 additions and 26 deletions
|
@ -92,33 +92,30 @@ 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)
|
(repo (read-from-minibuffer
|
||||||
(let* ((user (ghubp-username))
|
"Clone repository (user/repo or url): "
|
||||||
(repo (read-from-minibuffer
|
(if user (concat user "/"))
|
||||||
"Clone repository (user/repo or url): "
|
nil nil '+magit-clone-history))
|
||||||
(if user (concat user "/"))
|
(name (car (last (split-string repo "/" t)))))
|
||||||
nil nil '+magit-clone-history))
|
(list repo
|
||||||
(name (car (last (split-string repo "/" t)))))
|
(read-directory-name
|
||||||
(list repo
|
"Destination: "
|
||||||
(read-directory-name
|
magit-clone-default-directory
|
||||||
"Destination: "
|
name nil name))))
|
||||||
magithub-clone-default-directory
|
(magit-clone
|
||||||
name nil name)))))
|
(cond ((string-match-p "^[^/]+$" url-or-repo)
|
||||||
(require 'magithub)
|
(format +magit-default-clone-url (ghub--username (ghub--host)) url-or-repo))
|
||||||
(if (string-match "^\\([^/]+\\)/\\([^/]+\\)$" url-or-repo)
|
((string-match-p "^\\([^/]+\\)/\\([^/]+\\)/?$" url-or-repo)
|
||||||
(let ((repo `((owner (login . ,(match-string 1 url-or-repo)))
|
(apply #'format +magit-default-clone-url (split-string url-or-repo "/" t)))
|
||||||
(name . ,(match-string 2 url-or-repo)))))
|
(url-or-repo))
|
||||||
(and (or (magithub-request
|
dir))
|
||||||
(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)))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue