diff --git a/README.md b/README.md index f76c759..1c9b321 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ To see the pre-defined sub-commands, run `gita -h` or take a look at [cmds.yml](https://github.com/nosarthur/gita/blob/master/gita/cmds.yml). To add your own sub-commands, see the [customization section](#custom). To run arbitrary `git` command, see the [superman mode section](#superman). +To run arbitrary shell command, see the [shell mode section](#shell). The branch color distinguishes 5 situations between local and remote branches: @@ -157,6 +158,21 @@ For example, - `gita super frontend-repo backend-repo commit -am 'implement a new feature'` executes `git commit -am 'implement a new feature'` for `frontend-repo` and `backend-repo` +## Shell mode + +The shell mode delegates any shell command. +Usage: + +``` +gita shell [repo-name(s) or group-name(s)] +``` + +Here `repo-name(s)` or `group-name(s)` are optional, and their absence means all repos. +For example, + +- `gita shell ll` lists contents for all repos +- `gita shell repo1 mkdir docs` create a new directory `docs` in repo1 + ## Customization ### user-defined sub-command using yaml file @@ -195,6 +211,12 @@ comaster: help: checkout the master branch ``` +### customize the local/remote relationship coloring displayed by the `gita ll` command + +You can see the default color scheme and the available colors via `gita color`. +To change the color coding, use `gita color set `. +The configuration is saved in `$XDG_CONFIG_HOME/gita/color.yml`. + ### customize information displayed by the `gita ll` command You can customize the information displayed by `gita ll`. @@ -208,12 +230,6 @@ For example, the default information items setting corresponds to - commit_msg ``` -### customize the local/remote relationship coloring displayed by the `gita ll` command - -You can see the default color scheme and the available colors via `gita color`. -To change the color coding, use `gita color set `. -The configuration is saved in `$XDG_CONFIG_HOME/gita/color.yml`. - ## Requirements Gita requires Python 3.6 or higher, due to the use of diff --git a/tests/test_main.py b/tests/test_main.py index 2f51acf..ad501f7 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -159,6 +159,20 @@ def test_superman(mock_run, _, input): mock_run.assert_called_once_with(expected_cmds, cwd='path7') +@pytest.mark.parametrize('input', [ + 'diff --name-only --staged', + "commit -am 'lala kaka'", +]) +@patch('gita.utils.get_repos', return_value={'repo7': 'path7'}) +@patch('subprocess.run') +def test_shell(mock_run, _, input): + mock_run.reset_mock() + args = ['shell', 'repo7'] + shlex.split(input) + __main__.main(args) + expected_cmds = shlex.split(input) + mock_run.assert_called_once_with(expected_cmds, cwd='path7', check=True, stderr=-2, stdout=-1) + + class TestContext: @patch('gita.utils.get_context', return_value=None)