nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: awdeorio/mailmerge
Pull request #83 (2020-02-05 12:22:39)

Avoid irrelevant hints
It's irrelevant to hint the user to `--resume 1`. The first message is the default, and this hint is confusing.




Patch:
diff --git a/mailmerge/__main__.py b/mailmerge/__main__.py
index b59bb64..8195a9f 100644
--- a/mailmerge/__main__.py
+++ b/mailmerge/__main__.py
@@ -127,11 +127,16 @@ def main(sample, dry_run, limit, no_limit, resume,
             )
             message_num += 1
     except MailmergeError as error:
+        hint_text = '\nHint: "--resume {}"'.format(message_num)
         sys.exit(
             "Error on message {message_num}\n"
-            "{error}\n"
-            'Hint: "--resume {message_num}"'
-            .format(message_num=message_num, error=error)
+            "{error}"
+            "{hint}"
+            .format(
+                message_num=message_num,
+                error=error,
+                hint=(hint_text if message_num > 1 else ""),
+            )
         )
 
     # Hints for user


Test patch:
diff --git a/tests/test_main.py b/tests/test_main.py
index e1b0d26..3e1fd9f 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -799,7 +799,7 @@ def test_resume_too_big(tmpdir):
 
 
 def test_resume_hint_on_config_error(tmpdir):
-    """Verify --resume hint after config file read error."""
+    """Verify *no* --resume hint when error is after first message."""
     # Simple template
     template_path = Path(tmpdir/"mailmerge_template.txt")
     template_path.write_text(textwrap.dedent(u"""\
@@ -830,7 +830,7 @@ def test_resume_hint_on_config_error(tmpdir):
     stdout = error.value.stdout.decode("utf-8")
     stderr = error.value.stderr.decode("utf-8")
     assert stdout == ""
-    assert "--resume 1" in stderr
+    assert "--resume 1" not in stderr
 
 
 def test_resume_hint_on_csv_error(tmpdir):
Repository: awdeorio/mailmerge
Pull request #116 (2021-03-06 22:53:18)

Use New-Line-to-Break markdown extension
## Context

While testing #115, I noticed that newline characters (`'\n'`) in a markdown template were not rendered on both Gmail and on the native MacOS mail client.

This commit includes the Python Markdown extension [`nl2br`](https://python-markdown.github.io/extensions/nl2br/) to include HTML `<br />` tags whenever single newline characters are present in the Markdown.

## Validation

I used the following `mailmerge_template.txt`:

```
TO: {{email}}
SUBJECT: Testing mailmerge
FROM: Sesh <sesh.sadasivam@gmail.com>
Content-type: text/markdown

Hi {{ name }},

This is a _mailmerge_ test.

Best,
Sesh
```

In the screenshots below, notice the line-break in `Best, Sesh`.

<table>
<tr>
  <th></th>
  <th>Before</th>
  <th>After</th>
</tr>
<tr>
  <th>Gmail</th>
  <td><img src="https://user-images.githubusercontent.com/12139762/110223832-a69d6000-7ea4-11eb-9849-fb77bcc435ef.png"></td>
  <td><img src="https://user-images.githubusercontent.com/12139762/110223174-6dfd8680-7ea4-11eb-8657-6acc4cea67a7.png"></td>
</tr>
<tr>
  <th>MacOS Mail app</th>
  <td><img src="https://user-images.githubusercontent.com/12139762/110223824-95545380-7ea4-11eb-9ced-fff0390990ea.png"></td>
  <td><img src="https://user-images.githubusercontent.com/12139762/110222947-427a9c00-7ea4-11eb-85a1-040dbac03610.png"></td>
</tr>
</table>


Patch:
diff --git a/mailmerge/template_message.py b/mailmerge/template_message.py
index 0704821..9ea5caa 100644
--- a/mailmerge/template_message.py
+++ b/mailmerge/template_message.py
@@ -156,7 +156,7 @@ class TemplateMessage(object):
         # substitution works properly in Python 2.
         #
         # https://docs.python.org/3/library/email.mime.html#email.mime.text.MIMEText
-        html = markdown.markdown(text)
+        html = markdown.markdown(text, extensions=['nl2br'])
         payload = future.backports.email.mime.text.MIMEText(
             u"<html><body>{}</body></html>".format(html),
             _subtype="html",


Test patch:
diff --git a/tests/test_template_message.py b/tests/test_template_message.py
index 621a2bd..798c8d8 100644
--- a/tests/test_template_message.py
+++ b/tests/test_template_message.py
@@ -294,7 +294,7 @@ def test_markdown(tmp_path):
                         .decode(html_encoding)
 
     # Verify rendered Markdown
-    rendered = markdown.markdown(plaintext)
+    rendered = markdown.markdown(plaintext, extensions=['nl2br'])
     htmltext_correct = "<html><body>{}</body></html>".format(rendered)
     assert htmltext.strip() == htmltext_correct.strip()
 
@@ -335,7 +335,8 @@ def test_markdown_encoding(tmp_path):
     plaintext = plaintext_part.get_payload(decode=True).decode("utf-8")
     htmltext = html_part.get_payload(decode=True).decode("utf-8")
     assert plaintext == u"Hi, Myself,\næøå"
-    assert htmltext == u"<html><body><p>Hi, Myself,\næøå</p></body></html>"
+    assert htmltext == \
+        u"<html><body><p>Hi, Myself,<br />\næøå</p></body></html>"
 
 
 Attachment = collections.namedtuple(