Last active
September 21, 2022 07:49
-
-
Save xuhdev/d3bedab389b630957a97430ccfc17f96 to your computer and use it in GitHub Desktop.
Send Git Patches with GUI Email Clients https://www.topbug.net/blog/2016/12/13/send-git-patches-with-gui-email-clients/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# This file is licensed under CC0 <https://creativecommons.org/publicdomain/zero/1.0/legalcode> | |
# https://www.topbug.net/blog/2016/12/13/send-git-patches-with-gui-email-clients/ | |
import sys | |
import webbrowser | |
try: | |
from urllib.parse import quote # python 3 | |
except: | |
from urllib import quote # python 2 | |
SUBJECT_PREFIX = 'Subject:' | |
if len(sys.argv) >= 2: | |
to = sys.argv[1] | |
else: | |
to = '' | |
# Determine the subject | |
for line in sys.stdin: | |
line = line.strip() | |
if line.startswith(SUBJECT_PREFIX): | |
subject = line[len(SUBJECT_PREFIX):].strip() | |
break | |
# Determine the body | |
body = '' | |
for line in sys.stdin: | |
body += line | |
webbrowser.open('mailto:?To={}&Subject={}&Body={}'.format(quote(to), quote(subject), quote(body))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment