From 8d7aeaaa6639457d1fdc2db6a5755a6a59c6c0fa Mon Sep 17 00:00:00 2001 From: Alejandro Saucedo Date: Sun, 6 Oct 2024 12:03:33 +0200 Subject: [PATCH 1/4] Added contrib command Signed-off-by: Alejandro Saucedo --- sh.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sh.py b/sh.py index 556df8ff..4a83a3ac 100644 --- a/sh.py +++ b/sh.py @@ -3471,6 +3471,12 @@ def git(orig): # pragma: no cover return cmd +@contrib("bash") +def bash(orig): + cmd = orig.bake("-c") + return cmd + + @contrib("sudo") def sudo(orig): # pragma: no cover """a nicer version of sudo that uses getpass to ask for a password, or From 1c79351bb2177c62eee8c479b5111b6ae61f9d8e Mon Sep 17 00:00:00 2001 From: Alejandro Saucedo Date: Sun, 6 Oct 2024 12:08:18 +0200 Subject: [PATCH 2/4] Added documentation for bash contrib command Signed-off-by: Alejandro Saucedo --- docs/source/sections/contrib.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/source/sections/contrib.rst b/docs/source/sections/contrib.rst index c18877ee..dd189437 100644 --- a/docs/source/sections/contrib.rst +++ b/docs/source/sections/contrib.rst @@ -130,6 +130,32 @@ this. The currently written character. + +.. _contrib_bash: + +Bash +--- + +Often users may find themselves having to run bash commands directly, whether due +to commands having special characters (e.g. dash, or dot) or other reasons. +This can lead into recurrently having to bake the ``bash`` command to call it directly. To +account for this, the contrib version provides a ``bash`` command baked in: + +.. py:function:: bash(*args, **kwargs) + + Call bash with the prefix of "bash -c [...]". + +.. code-block:: python + + from sh.contrib import bash + + # Calling commands directly + bash.ls() # equivallent to "bash -c ls" + + # Or adding the full commands + bash("command-with-dashes args") + + Extending ========= From 824f9feccc8a3178ae83209f5ea68aa6ab2899dd Mon Sep 17 00:00:00 2001 From: Andrew Moffat Date: Tue, 8 Oct 2024 23:35:30 -0700 Subject: [PATCH 3/4] fixing action versions --- .github/workflows/main.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8778236..2dabbdd2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,22 +14,22 @@ jobs: name: Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: actions/cache@v2 + - uses: actions/cache@v4 name: Cache pip directory with: path: ~/.cache/pip key: ${{ runner.os }}-pip-3.9 - - uses: actions/cache@v2 + - uses: actions/cache@v4 name: Cache poetry deps with: path: .venv key: ${{ runner.os }}-build-${{ hashFiles('poetry.lock') }}-3.9 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.9 @@ -60,15 +60,15 @@ jobs: lang: [C, en_US.UTF-8] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: actions/cache@v2 + - uses: actions/cache@v4 name: Cache pip directory with: path: ~/.cache/pip key: ${{ runner.os }}-pip-3.9 - - uses: actions/cache@v2 + - uses: actions/cache@v4 name: Cache poetry deps env: cache-name: poetry-deps @@ -77,7 +77,7 @@ jobs: key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('poetry.lock') }}-${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -95,7 +95,7 @@ jobs: SH_TESTS_RUNNING=1 SH_TESTS_USE_SELECT=${{ matrix.use-select }} LANG=${{ matrix.lang }} poetry run coverage run -a -m pytest - name: Store coverage - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: coverage.${{ matrix.use-select }}.${{ matrix.lang }}.${{ matrix.python-version }} path: .coverage @@ -106,10 +106,10 @@ jobs: runs-on: ubuntu-latest steps: # required because coveralls complains if we're not in a git dir - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.9 @@ -118,7 +118,7 @@ jobs: pip install coverage coveralls - name: Download coverage artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: path: coverage-artifacts @@ -143,7 +143,7 @@ jobs: id-token: write steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Get current version id: get_version @@ -155,7 +155,7 @@ jobs: git push -f origin "${{steps.get_version.outputs.version}}" - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.9 From 5e5b50d4902883b9a7c56451ce63db06e513893d Mon Sep 17 00:00:00 2001 From: Andrew Moffat Date: Tue, 8 Oct 2024 23:44:13 -0700 Subject: [PATCH 4/4] fixing broken coverage --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2dabbdd2..5bed69cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -92,13 +92,13 @@ jobs: - name: Run tests run: | - SH_TESTS_RUNNING=1 SH_TESTS_USE_SELECT=${{ matrix.use-select }} LANG=${{ matrix.lang }} poetry run coverage run -a -m pytest + SH_TESTS_RUNNING=1 SH_TESTS_USE_SELECT=${{ matrix.use-select }} LANG=${{ matrix.lang }} poetry run coverage run --data-file=coverage.data -a -m pytest - name: Store coverage uses: actions/upload-artifact@v4 with: name: coverage.${{ matrix.use-select }}.${{ matrix.lang }}.${{ matrix.python-version }} - path: .coverage + path: coverage.data report: name: Report Coverage @@ -124,7 +124,7 @@ jobs: - name: Combine coverage run: | - find coverage-artifacts -name .coverage | xargs coverage combine -a + find coverage-artifacts -name coverage.data | xargs coverage combine -a - name: Report coverage env: