Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
Overhang.IO committed Sep 19, 2024
2 parents 5f1e6be + 2959e6e commit 487a433
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/20240816_141531_regis_patches_show.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [Feature] Add a `patches show my-patch-name`. This is a convenient command for the troubleshooting of plugins. (by @regisb)
5 changes: 5 additions & 0 deletions tests/commands/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,8 @@ def test_config_patches_list(self) -> None:
result = self.invoke_in_root(root, ["config", "patches", "list"])
self.assertFalse(result.exception)
self.assertEqual(0, result.exit_code)

def test_config_patches_show(self) -> None:
result = self.invoke(["config", "patches", "show", "mypatch"])
self.assertEqual(0, result.exit_code)
self.assertEqual("", result.stdout)
12 changes: 12 additions & 0 deletions tutor/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,20 @@ def patches_list(context: Context) -> None:
renderer.print_patches_locations()


@click.command(name="show", help="Print the rendered contents of a template patch")
@click.argument("name")
@click.pass_obj
def patches_show(context: Context, name: str) -> None:
config = tutor_config.load_full(context.root)
renderer = env.Renderer(config)
rendered = renderer.patch(name)
if rendered:
print(rendered)


config_command.add_command(save)
config_command.add_command(printroot)
config_command.add_command(printvalue)
patches_command.add_command(patches_list)
patches_command.add_command(patches_show)
config_command.add_command(patches_command)
4 changes: 1 addition & 3 deletions tutor/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

from __future__ import annotations

import functools
import typing as t
from copy import deepcopy

from tutor import exceptions, fmt, hooks
from tutor.types import Config, get_typed
from tutor.types import Config

# Import modules to trigger hook creation
from . import openedx, v0, v1
Expand Down

0 comments on commit 487a433

Please sign in to comment.