Skip to content

[pre-commit.ci] pre-commit autoupdate #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
13 changes: 9 additions & 4 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@

name: pre-commit

on:
pull_request:
push:
branches: [main]
on: [push, pull_request]

jobs:
pre-commit:
# External pull requests should be checked, but not our own internal pull
# requests again, as these are already checked by the push on the branch.
# Without this if condition, the checks would be performed twice, as
# internal pull requests correspond to both the push and pull_request
# events.
if:
github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repos:
- id: sphinx-lint
types: [rst]
- repo: https://github.com/pycqa/isort
rev: 6.0.0
rev: 6.0.1
hooks:
- id: isort
additional_dependencies: ["toml"]
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ Added
* 📝 Add csv.Sniffer methods
* 📝 Add the removal of git lfs


Changed
~~~~~~~

* 📝 Update git section

* Add diff source and destination prefix
* Add default branch config for init
* Add git-symbolic-ref
* Add Git Credential Store for Linux
* Update shallow clones
* Add shell config and command line tools

`24.3.0 <https://github.com/cusyio/Python4DataScience/compare/24.2.0...24.3.0>`_: 2024-11-03
--------------------------------------------------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ Follow us
Pull-Requests
-------------

If you have suggestions for improvements and additions, I recommend that you
create a `Fork <https://github.com/cusyio/python4datascience/fork>`_ of my
If you have suggestions for improvements and additions, we recommend that you
create a `Fork <https://github.com/cusyio/python4datascience/fork>`_ of our
`GitHub Repository <https://github.com/cusyio/python4datascience/>`_ and make
your changes there. You are also welcome to make a *pull request*. If the
changes contained therein are small and atomic, I’ll be happy to look at your
changes contained therein are small and atomic, we will be happy to look at your
suggestions.

The following guidelines help us to maintain the German translation of the
Expand Down
21 changes: 20 additions & 1 deletion docs/productive/git/advanced/batch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Example
changes the permissions for all files with the suffix ``.py`` from
``100644`` to ``100755``, if necessary, so that they become executable.

.. _git-name-only:

All files changed in the working or staging area
------------------------------------------------

Expand All @@ -35,9 +37,26 @@ All files changed in the working or staging area
:samp:`git diff --staged --name-only "*.{SUFFIX}"`
also filters for a specific file extension.

.. _list-changed:

:samp:`git diff --name-only --diff-filter d`
excludes deleted files.

This is the most common case for me, which is why I have created a
``list-changed`` alias for this: ``git config --global alias.list-changed
'diff --name-only --diff-filter d'``.

Example
~~~~~~~

:samp:`pytest $(git diff --staged --name-only "tests/test_*.py")`
To execute commands for the changed file list, you can use the shell `Command
Substitution
<https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html>`_:

:samp:`$ uv run codespell $(git list-changed '*.py')`
The shell executes the ``git list-changed`` in brackets and inserts its
output into the outer command. ``codespell`` therefore receives the list of
changed text files as an argument.
:samp:`uv run pytest $(git diff --staged --name-only "tests/*test_*.py")`
calls :doc:`python-basics:test/pytest/index` to execute only those test
modules that have been changed in the working directory.
105 changes: 88 additions & 17 deletions docs/productive/git/advanced/binary-files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ Then we can use :doc:`pandas:reference/api/pandas.DataFrame.to_csv` in
:language: python

Now add the following section to your global Git configuration
:file:`~/.gitconfig`:
:file:`~/.config/git/config`:

.. code-block:: ini

[diff "excel"]
textconv=python3 /PATH/TO/exceltocsv.py
binary=true

Finally, in the global :file:`~/.gitattributes` file, our ``excel`` converter is
linked to :file:`*.xlsx` files:
Finally, in the global :file:`~/.config/git/attributes` file, our ``excel``
converter is linked to :file:`*.xlsx` files:

.. code-block:: ini

Expand All @@ -56,15 +56,16 @@ For this, ``pdftohtml`` is additionally required. It can be installed with

$ brew install pdftohtml

Add the following section to the global Git configuration :file:`~/.gitconfig`:
Add the following section to the global Git configuration
:file:`~/.config/git/config`:

.. code-block:: ini

[diff "pdf"]
textconv=pdftohtml -stdout

Finally, in the global :file:`~/.gitattributes` file, our ``pdf`` converter is
linked to :file:`*.pdf` files:
Finally, in the global :file:`~/.config/git/attributes` file, our ``pdf``
converter is linked to :file:`*.pdf` files:

.. code-block:: ini

Expand All @@ -73,10 +74,12 @@ linked to :file:`*.pdf` files:
Now, when ``git diff`` is called, the PDF files are first converted and then a
diff is performed over the outputs of the converter.

… for Word documents
--------------------
.. _pandoc-to-markdown:

Differences in Word documents can also be displayed. For this purpose `Pandoc
… for documents
---------------

Differences in documents can also be displayed. For this purpose `Pandoc
<https://pandoc.org/>`_ can be used, which can be easily installed with

.. tab:: Debian/Ubuntu
Expand All @@ -97,24 +100,92 @@ Differences in Word documents can also be displayed. For this purpose `Pandoc
<https://github.com/jgm/pandoc/releases/>`_.

Then add the following section to your global Git configuration
:file:`~/.gitconfig`:
:file:`~/.config/git/attributes`:

.. code-block:: ini

[diff "word"]
textconv=pandoc --to=markdown
binary=true
prompt=false
[diff "pandoc-to-markdown"]
textconv = pandoc --to markdown
cachetextconv = true

Finally, in the global :file:`~/.gitattributes` file, our ``word`` converter is
linked to :file:`*.docx` files:
Finally, in the global :file:`~/.config/git/attributes` file, our
``pandoc-to-markdown`` converter is linked to :file:`*.docx`, :file:`*.odt` and
:file:`*.rtf` files:

.. code-block:: ini

*.docx diff=word
*.docx diff=pandoc-to-markdown
*.odt diff=pandoc-to-markdown
*.rtf diff=pandoc-to-markdown

.. tip::
:doc:`Jupyter Notebooks <jupyter-tutorial:notebook/index>` write to a JSON
file :ref:`*.ipynb <jupyter-tutorial:whats-an-ipynb-file>`, which is quite
dense and difficult to read, especially with diffs. The Markdown
representation of Pandoc simplifies this:

.. code-block:: ini

*.ipynb diff=pandoc-to-markdown

The same procedure can be used to obtain useful diffs from other binaries, for
example ``*.zip``, ``*.jar`` and other archives with ``unzip`` or for changes in
the meta information of images with ``exiv2``. There are also conversion tools
for converting ``*.odt``, ``*.doc`` and other document formats into plain text.
For binary files for which there is no converter, strings are often sufficient.

.. _exiftool:

… for media files
-----------------

`ExifTool <https://exiftool.org>`_ can be used to convert the metadata of media
files to text.

.. tab:: Debian/Ubuntu

.. code-block:: console

$ sudo apt install libimage-exiftool-perl

.. tab:: macOS

.. code-block:: console

$ brew install exiftool

.. tab:: Windows

.. code-block:: ps1

> choco install exiftool

.. seealso::
* `Installing ExifTool <https://exiftool.org/install.html>`_

You can then add the following section to the global Git configuration file
:file:`~/.config/git/config`:

.. code-block:: ini

[diff "exiftool"]
textconv = exiftool --composite -x 'Exiftool:*'
cachetextconv = true
xfuncname = "^-.*$"

Finally, in :file:`~/.config/git/attributes` the ``exiftool`` converter is
linked to file endings of media files:

.. code-block:: ini

*.avif diff=exiftool
*.bmp diff=exiftool
*.gif diff=exiftool
*.jpeg diff=exiftool
*.jpg diff=exiftool
*.png diff=exiftool
*.webp diff=exiftool

.. seealso::
``exiftool`` can process many more media files. You can find a complete list
in `Supported File Types <https://exiftool.org/#supported>`_.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/productive/git/advanced/delta.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions docs/productive/git/advanced/gitlab/github-migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ GitHub Actions syntax for jobs
jobs:
my_job:
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: echo "Run my script here"

GitLab CI/CD syntax for jobs
Expand Down Expand Up @@ -137,7 +137,6 @@ GitHub syntax for conditions and expressions
steps:
- run: echo "Deploy to production server"


GitLab syntax for conditions and expressions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -309,7 +308,7 @@ GitHub Actions syntax for databases and service containers

steps:
- name: Python
uses: actions/checkout@v3
uses: actions/checkout@v4
uses: actions/setup-python@v4
with:
python-version: '3.10'
Expand Down
Loading
Loading