File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ from pathlib import Path
2
+
1
3
import click
2
4
3
5
from ..util import get_problem_total_points , load_problems_metadata
@@ -37,5 +39,35 @@ def summary_command() -> None:
37
39
print (f" - { name :<40} { score_section :>20} " )
38
40
39
41
42
+ @cli .command (name = "rebase-todo-injector" )
43
+ @click .argument ("todo_items_file_path" )
44
+ @click .argument ("path" )
45
+ def rebase_todo_injector_command (todo_items_file_path , path ) -> None :
46
+ """
47
+ An 'editor' that inject pre-made todo items for git interactive rebase.
48
+
49
+ It assumes that the pre-made todo items file is named 'rebase-todo-items.txt'
50
+ and it is in the current working directory.
51
+
52
+ This command cannot be used directly, you want to create a script file that call
53
+ this command.
54
+
55
+ Example script file:
56
+ #!/bin/bash
57
+ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
58
+ python -m grading_lib rebase-todo-injector $SCRIPT_DIR/../rebase-todo-items.txt $1
59
+ """
60
+ todo_items_file_path = Path (todo_items_file_path )
61
+ if not todo_items_file_path .exists ():
62
+ raise FileNotFoundError (
63
+ f"Cannot find '{ todo_items_file_path } ' in the current working directory (cwd='{ Path ("." ).absolute ()} ')"
64
+ )
65
+ with open (todo_items_file_path ) as in_f :
66
+ todo_items_content = in_f .read ()
67
+
68
+ with open (path , "w" ) as out_f :
69
+ out_f .write (todo_items_content )
70
+
71
+
40
72
cli .add_command (dev )
41
73
cli .add_command (internal )
You can’t perform that action at this time.
0 commit comments