Skip to content

Instantly share code, notes, and snippets.

@colonelpanic8
Created June 20, 2016 00:20
Show Gist options
  • Select an option

  • Save colonelpanic8/f5659a88c2c8312d30ee4733579a9774 to your computer and use it in GitHub Desktop.

Select an option

Save colonelpanic8/f5659a88c2c8312d30ee4733579a9774 to your computer and use it in GitHub Desktop.
(defun github-clone-get-repo-name-from-remote (&optional remote)
(unless remote
(setq remote
(magit-read-remote "Select a remote: ")))
(github-clone-repo-name
(magit-get "remote" remote "url")))
(defun github-clone-fork-remote (&optional remote)
(interactive (list (magit-read-remote "Select a remote")))
(cl-destructuring-bind (user . repo)
(github-clone-get-repo-name-from-remote remote)
(github-clone-fork-repo (github-clone-info user repo))))
(defun github-clone-add-existing-remote (&optional remote-in-network)
(interactive
(list (magit-read-remote "Select the remote whose network you would like to search")))
(cl-destructuring-bind (user . repo)
(github-clone-get-repo-name-from-remote remote-in-network)
(let ((candidates (github-clone-remotes user repo)))
(cl-destructuring-bind (selected-user . selected-repo)
(assoc (completing-read "Select a remote to add: " candidates) candidates)
(magit-remote-add selected-user selected-repo)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment