Repository: repobee/repobee-feedback

Issue:
Reformat issue confirmation output on using Multi Issue File
Right now when opening issues repobee asks for confirmation on these and the way the text is formatted doesn't really do it for my eyes.
```
wagmode$ repobee issues feedback --mi issues.md -a task-15
Processing issue "Pass" for student1-task-15: Now this is c++!

dolor sit amet
Open issue "Pass" in repo student1-task-15? (y/n) y
Processing issue "Fail" for student2-task-15: 
Open issue "Fail" in repo student2-task-15? (y/n) y
Processing issue "Pass" for student3-task-15: more lorem ipsum, 

more dolor sit amet
Open issue "Pass" in repo student3-task-15? (y/n) 
````
I think this feels a bit cluttered, especially when each issue is given one by one it is sometimes difficult to directly see what is the new/old issue. Instead I would want something like this:

```
wagmode$ repobee issues feedback --mi issues.md -a task-15

Processing issue "Pass" for student1-task-15: 
    >Now this is c++!
    >
    >lorem ispum dolor sit amet
Open issue "Pass" in repo student1-task-15? (y/n) y

Processing issue "Fail" for student2-task-15: 
Open issue "Fail" in repo student2-task-15? (y/n) y

Processing issue "Pass" for student3-task-15: 
    >More Lorem isum
    >
    >More dolor sit amet
Open issue "Pass" in repo student3-task-15? (y/n) 
```

So the changes i can think of right now is:
* Separate each issue with empty line
* Indent issue text and/or place in some kind of block

This becomes even more usefull for larger issues. 

Alternatively, we can also make it so that when a new issue is shown in the terminal we make it so that while in "approval mode" only the current issue is shown. @slarse  what do you think?

Comments:

Patch:
diff --git a/repobee_feedback/feedback.py b/repobee_feedback/feedback.py
index 6014698..f4ceb59 100644
--- a/repobee_feedback/feedback.py
+++ b/repobee_feedback/feedback.py
@@ -11,6 +11,7 @@ import pathlib
 import re
 import sys
 import argparse
+from textwrap import indent
 from typing import Iterable, Tuple, List, Mapping
 
 import repobee_plug as plug
@@ -18,6 +19,8 @@ import repobee_plug as plug
 PLUGIN_NAME = "feedback"
 
 BEGIN_ISSUE_PATTERN = r"#ISSUE#(.*?)#(.*)"
+INDENTATION_STR = "    "
+TRUNC_SIGN = "[...]"
 
 
 def callback(args: argparse.Namespace, api: plug.PlatformAPI) -> None:
@@ -108,20 +111,20 @@ class Feedback(plug.Plugin, plug.cli.Command):
         callback(self.args, api)
 
 
+def _indent_issue_body(body: str, trunc_len: int):
+    indented_body = indent(body[:trunc_len], INDENTATION_STR)
+    body_end = TRUNC_SIGN if len(body) > trunc_len else ""
+    return indented_body + body_end
+
+
 def _ask_for_open(issue: plug.Issue, repo_name: str, trunc_len: int) -> bool:
-    plug.echo(
-        'Processing issue "{}" for {}: {}{}'.format(
-            issue.title,
-            repo_name,
-            issue.body[:trunc_len],
-            "[...]" if len(issue.body) > trunc_len else "",
-        )
+    indented_body = _indent_issue_body(issue.body, trunc_len)
+    issue_description = (
+        f'\nProcessing issue "{issue.title}" for {repo_name}:\n{indented_body}'
     )
+    plug.echo(issue_description)
     return (
-        input(
-            'Open issue "{}" in repo {}? (y/n) '.format(issue.title, repo_name)
-        )
-        == "y"
+        input(f'Open issue "{issue.title}" in repo {repo_name}? (y/n) ') == "y"
     )
 
 


Test patch:
diff --git a/tests/test_feedback.py b/tests/test_feedback.py
index 790e602..67667d4 100644
--- a/tests/test_feedback.py
+++ b/tests/test_feedback.py
@@ -223,3 +223,26 @@ class TestCallback:
         feedback.callback(args=args, api=api_mock)
 
         api_mock.create_issue.assert_has_calls(expected_calls, any_order=True)
+
+
+class TestIndentIssueBody:
+    """Tests for the method that addds indentation to the issue body"""
+
+    def test_issue_indented_and_truncated(
+        self,
+    ):
+        """Test that a long issue body get truncated to a certain length"""
+        body = "Hello world\nfrom python\n"
+        indented_body = feedback._indent_issue_body(
+            body, trunc_len=len(body) // 2
+        )
+        assert indented_body.startswith(f"{feedback.INDENTATION_STR}Hello")
+        assert indented_body.endswith(feedback.TRUNC_SIGN)
+
+    def test_issue_indented_and_not_truncated(
+        self,
+    ):
+        """Test that a short issue body does not get truncated"""
+        body = "This is an issue\n"
+        indented_body = feedback._indent_issue_body(body, 2 * len(body))
+        assert indented_body == f"{feedback.INDENTATION_STR}{body}"