~sircmpwn/git-send-email.io

ed6abed3cb2312a7ff24cc42a4dc3c5ec00e3909 — Drew DeVault 3 years ago b424e9d
Ditch pystache
M email_tutorial/app.py => email_tutorial/app.py +4 -5
@@ 3,13 3,13 @@ from email.utils import parseaddr, make_msgid, formatdate
from email.mime.text import MIMEText
from flask import Flask, request
from srht.config import cfg, cfgi
from string import Template
from urllib.parse import quote as urlquote
import email
import html.parser
import json
import os
import pygit2
import pystache
import re
import smtplib



@@ 23,9 23,8 @@ smtp_password = cfg("mail", "smtp-password", default=None)
def render_template(templ, **kwargs):
    path = os.path.join(os.path.dirname(__file__), "replies", templ)
    with open(path) as f:
        body = html.parser.HTMLParser().unescape(
            pystache.render(f.read(), kwargs))
    return body
        tmpl = Template(f.read())
        return tmpl.substitute(**kwargs)

def send_reply(original, reply):
    reply["From"] = "git-send-email.io <devnull@sr.ht>"


@@ 78,7 77,7 @@ def get_reply(diff, mail):
        msgid = make_msgid()
        reply = MIMEText(render_template("stage-1-success", **{
            "from": from_[0],
            "new_file": patch.delta.new_file,
            "new_file_path": patch.delta.new_file.path,
            "content": content.rstrip(),
            "msgid": msgid,
            "msgid_url": urlquote(msgid),

M email_tutorial/replies/not-a-patch => email_tutorial/replies/not-a-patch +1 -2
@@ 1,5 1,4 @@
{{! vim: set ft=email tw=72 }}
Hi{{#from}} {{from}}{{/from}}!
Hi $from!

We got your email, but it doesn't look like a patch. Did you use git
send-email to generate it? Generally speaking, using other tools to

M email_tutorial/replies/stage-1-success => email_tutorial/replies/stage-1-success +4 -5
@@ 1,11 1,10 @@
{{! vim: set ft=email tw=72 }}
Hi{{#from}} {{from}}{{/from}}!
Hi $from!

Thanks for the patch! Needs a minor fix, though:

> diff --git a/{{new_file.path}} b/{{new_file.path}}
> diff --git a/$new_file_path b/$new_file_path
> -%<-
> +{{content}}
> +$content

This statement is no longer correct - you have already tried it, and
succeeded! Can you change this to the following:


@@ 14,7 13,7 @@ succeeded! Can you change this to the following:

After you make the change, you can edit your commit like so:

	git add {{new_file.path}}
	git add $new_file_path
	git commit --amend

Then send along a v2 of your first patch:

M email_tutorial/replies/stage-2-success => email_tutorial/replies/stage-2-success +1 -2
@@ 1,5 1,4 @@
{{! vim: set ft=email tw=72 }}
Hi{{#from}} {{from}}{{/from}}!
Hi $from!

Thanks for the updated patch! This one looks good. Great work :)


M email_tutorial/replies/too-many-files => email_tutorial/replies/too-many-files +1 -2
@@ 1,5 1,4 @@
{{! vim: set ft=email tw=72 }}
Hi{{#from}} {{from}}{{/from}}!
Hi $from!

We got your patch, and it looks like a valid git patch. However, we were
only expecting one file to have changed - that is, adding a file named

M email_tutorial/replies/wrong-changes => email_tutorial/replies/wrong-changes +1 -2
@@ 1,5 1,4 @@
{{! vim: set ft=email tw=72 }}
Hi{{#from}} {{from}}{{/from}}!
Hi $from!

We got your patch, and it looks like a valid git patch. However, we were
expecting you to create a new file, named after yourself. You can run

M email_tutorial/replies/wrong-content => email_tutorial/replies/wrong-content +1 -2
@@ 1,5 1,4 @@
{{! vim: set ft=email tw=72 }}
Hi{{#from}} {{from}}{{/from}}!
Hi $from!

We got your patch, and it looks like a valid git patch. However, we were
expecting your new file to contain just one line, like this:

M setup.py => setup.py +0 -1
@@ 19,7 19,6 @@ setup(
  install_requires = [
    'flask',
    'pygit2',
    'pystache',
  ],
  license = 'MIT',
  package_data={