Skip to content

Instantly share code, notes, and snippets.

@diasjorge
Created August 9, 2017 22:50
Show Gist options
  • Save diasjorge/e3cb055b2655bacd45ea9f932a7a246c to your computer and use it in GitHub Desktop.
Save diasjorge/e3cb055b2655bacd45ea9f932a7a246c to your computer and use it in GitHub Desktop.
;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with C-o and enter text in its buffer.
(defun magithub--url->domain (url)
"Tries to parse a remote url into a domain"
(cdr (assq 'domain (magithub--parse-url url))))
(add-hook 'magit-status-mode-hook '(lambda ()
(if (magithub-github-repository-p)
(let* ((remote-url (magit-get "remote" (magithub-source--remote) "url"))
(domain (magithub--url->domain(remote-url))))
(setq ghub-base-url (concat "https://" domain "/api/v3/"))
))))
(cdr (assq 'domain (magithub--parse-url "[email protected]:example/project.git")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment