Skip to content

Instantly share code, notes, and snippets.

@tirkarthi
Created August 19, 2019 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tirkarthi/e25aabc406433fce7f45bcf6b719705e to your computer and use it in GitHub Desktop.
Save tirkarthi/e25aabc406433fce7f45bcf6b719705e to your computer and use it in GitHub Desktop.
Open the bug and PR for commit under cursor in magit mode
(defun python-bugs-url ()
(interactive)
(let ((commit-message (magit-rev-format "%B"
(magit-rev-parse
(magit-branch-or-commit-at-point))))
(bugs-base-url "https://bugs.python.org/issue")
(pr-base-url "https://github.com/python/cpython/pull/")
(bugs-pr-regex "bpo-\\([0-9]+\\).*\\(GH-\\|#\\)\\([0-9]+\\)"))
(when (string-match bugs-pr-regex commit-message)
(let ((bug-url (concat bugs-base-url (match-string 1 commit-message)))
(pr-url (concat pr-base-url (match-string 3 commit-message))))
(browse-url bug-url)
(browse-url pr-url)))))
(magit-define-popup-action 'magit-log-popup
?z
"Open bug in browser"
'python-bugs-url)
@stonecharioteer
Copy link

(my eyes!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment