Skip to content

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

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
12 changes: 12 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ 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-de/compare/24.2.0...24.3.0>`_: 2024-11-19
-----------------------------------------------------------------------------------------------

Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ Pull-Requests
-------------

Wenn ihr Vorschläge für Verbesserungen und Ergänzungen habt, empfehle ich euch,
einen `Fork <https://github.com/cusyio/Python4DataScience-de/fork>`_ meines
einen `Fork <https://github.com/cusyio/Python4DataScience-de/fork>`_ unseres
`GitHub-Repository <https://github.com/cusyio/Python4DataScience-de/>`_ zu
erstellen und darin eure Änderungen vorzunehmen. Gerne dürft ihr auch einen
*Pull Request* stellen. Sofern die darin enthaltenen Änderungen klein und
atomar sind, schaue ich mir eure Vorschläge gerne an.
atomar sind, schauen wir uns eure Vorschläge gerne an.

Da eine englischsprachige Übersetzung gepflegt wird, beachtet folgende
Richtlinien:

* Commit messages auf Englisch
* Commit messages mit einem `Gitmoji <https://gitmoji.dev/>`__ am Anfang
* Commit-Nachrichten auf Englisch
* Commit-Nachrichten mit einem `Gitmoji <https://gitmoji.dev/>`__ am Anfang
* Namen von Ordnern und Dateien auf Englisch.
32 changes: 30 additions & 2 deletions docs/productive/git/advanced/batch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,20 @@ die Kombination von `git ls-files <https://git-scm.com/docs/git-ls-files>`_ und
Beispiel
~~~~~~~~

:samp:`$ git ls-files -z -- "*.py" | xargs -0 git update-index --chmod=+x`
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')`
Die Shell führt das ``git list-changed`` in Klammern aus und fügt dessen
Ausgabe in den äußeren Befehl ein. ``codespell`` erhält also die Liste der
geänderten Textdateien als Argument.
:samp:`uv run pytest $(git diff --staged --name-only "tests/*test_*.py")`
ändert für alle Dateien mit dem Suffix ``.py`` ggf. die Berechtigungen von
``100644`` zu ``100755``, sodass sie ausführbar werden.

.. _git-name-only:

Alle im Arbeits- oder Bühnenbereich geänderten Dateien
------------------------------------------------------

Expand All @@ -35,10 +45,28 @@ Alle im Arbeits- oder Bühnenbereich geänderten Dateien
:samp:`git diff --staged --name-only "*.{SUFFIX}"`
filtert darüberhinaus noch nach einer bestimmten Dateiendung.

.. _list-changed:

:samp:`git diff --name-only --diff-filter d`
schließt gelöschte Dateien aus.

Dies ist bei mir der häufigste Fall, weswegen ich mir hierfür einen Alias
``list-changed`` angelegt habe: ``git config --global alias.list-changed
'diff --name-only --diff-filter d'``.

Beispiel
~~~~~~~~

:samp:`pytest $(git diff --staged --name-only "tests/test_*.py")`
Um Befehle für die geänderte Dateiliste auszuführen, könnt ihr die
Shell-`Command Substitution
<https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html>`_
verwenden:

:samp:`$ uv run codespell $(git list-changed '*.py')`
Die Shell führt das in Klammern gesetzte ``git list-changed`` aus und fügt
dessen Ausgabe in den äußeren Befehl ein. ``codespell`` erhält also die
Liste der geänderten Textdateien als Argument.
:samp:`uv run pytest $(git diff --staged --name-only "tests/*test_*.py")`
ruft :doc:`python-basics:test/pytest/index` auf, um anschließend nur
diejenigen Testmodule auszuführen, die im Arbeitsverzeichnis geändert
wurden.
107 changes: 88 additions & 19 deletions docs/productive/git/advanced/binary-files.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Git für Binärdateien
====================

Expand All @@ -25,16 +24,16 @@ Excel-Dateien verwenden:
:language: python
:lines: 5-

Nun fügt ihr noch in der globalen Git-Konfiguration in der Datei :file:`~/.gitconfig`
den folgenden Abschnitt hinzu:
Nun fügt ihr noch in der globalen Git-Konfiguration in der Datei
:file:`~/.config/git/config` den folgenden Abschnitt hinzu:

.. code-block:: ini

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

Schließlich wird in der globalen :file:`~/.gitattributes`-Datei unser
Schließlich wird in der globalen :file:`~/.config/git/attributes`-Datei unser
``excel``-Konverter mit :file:`*.xlsx`-Dateien verknüpft:

.. code-block:: ini
Expand All @@ -58,15 +57,15 @@ Hierfür wird zusätzlich ``pdftohtml`` benötigt. Ihr installiert es mit

$ brew install pdftohtml

Anschließend fügt ihr den folgenden Abschnitt der globalen Git-Konfiguration in der
Datei :file:`~/.gitconfig` hinzu:
Anschließend fügt ihr den folgenden Abschnitt der globalen Git-Konfiguration in
der Datei :file:`~/.config/git/config` hinzu:

.. code-block:: ini

[diff "pdf"]
textconv=pdftohtml -stdout

Schließlich wird in der globalen :file:`~/.gitattributes`-Datei unser
Schließlich wird in der globalen :file:`~/.config/git/attributes`-Datei unser
``pdf``-Konverter mit :file:`*.pdf`-Dateien verknüpft:

.. code-block:: ini
Expand All @@ -76,10 +75,10 @@ Schließlich wird in der globalen :file:`~/.gitattributes`-Datei unser
Nun wird beim Aufruf von ``git diff`` die PDF-Datei zunächst konvertiert und
dann ein Diff über den Ausgaben des Konverters durchgeführt.

… für Word-Dokumente
--------------------
… für Dokumente
---------------

Auch Unterschiede in Word-Dokumenten lassen sich anzeigen. Hierfür kann `Pandoc
Auch Unterschiede in Dokumenten lassen sich anzeigen. Hierfür kann `Pandoc
<https://pandoc.org/>`_ verwendet werden, das einfach installiert werden kann
mit

Expand All @@ -100,22 +99,34 @@ mit
Herunterladen und Installieren der aktuellen :file:`.msi`-Datei von `GitHub
<https://github.com/jgm/pandoc/releases/>`_.

Anschließend wird der globalen Git-Konfiguration :file:`~/.gitconfig` folgender
Abschnitt hinzugefügt:
Anschließend wird der globalen Git-Konfiguration :file:`~/.config/git/config`
folgender Abschnitt hinzugefügt:

.. code-block:: ini

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

Schließlich wird in der globalen :file:`~/.gitattributes`-Datei unser
``word``-Konverter mit :file:`*.docx`-Dateien verknüpft:
Schließlich wird in der globalen :file:`~/.config/git/attributes`-Datei unser
``pandoc-to-markdown``-Konverter mit :file:`*.docx`, :file:`*.odt` und
:file:`*.rtf`-Dateien verknüpft:

.. 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>` schreiben in eine
JSON-Datei :ref:`*.ipynb <jupyter-tutorial:was-ist-eine-ipynb-datei>`, die
ziemlich dicht und insbesondere bei Diffs schwer zu lesen ist. Die
Markdown-Darstellung von Pandoc vereinfact dies:

.. code-block:: ini

*.ipynb diff=pandoc-to-markdown

Die gleiche Vorgehensweise kann auch angewandt werden, um nützliche Diffs von
anderen Binärdateien zu erhalten, :abbr:`z.B. (zum Beispiel)` ``*.zip``,
Expand All @@ -124,3 +135,61 @@ Metainformationen von Bildern mit ``exiv2``. Zudem gibt es
Konvertierungswerkzeuge für die Umwandlung von :file:`*.odt`, :file:`*.doc` und
anderen Dokumentenformaten in einfachen Text. Für Binärdateien, für die es
keinen Konverter gibt, reichen oft auch Strings aus.

.. _exiftool:

… für Medien-Dateien
--------------------

`ExifTool <https://exiftool.org>`_ kann verwendet werden um die Metadaten der
Medien-Dateien in Text zu konvertieren.

.. 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>`_

Anschließend könnt ihr in der globalen Git-Konfigurationsdatei
:file:`~/.config/git/config` folgenden Abschnitt hinzufügen:

.. code-block:: ini

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

Schließlich wird in der :file:`~/.config/git/attributes` der
``exiftool``-Konverter mit Datei-Endungen von Medien-Dateien verknüpft:

.. 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`` kann noch viele weitere Medien-Dateien verarbeiten. Eine
vollständige Liste erhaltet ihr 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.
9 changes: 4 additions & 5 deletions docs/productive/git/advanced/gitlab/github-migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ GitHub Actions-Syntax für Jobs
jobs:
my_job:
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: echo "Run my script here"

GitLab CI/CD-Syntax für Jobs
Expand Down Expand Up @@ -143,7 +143,6 @@ GitHub-Syntax für Bedingungen und Ausdrücke
steps:
- run: echo "Deploy to production server"


GitLab-Syntax für Bedingungen und Ausdrücke
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -319,8 +318,8 @@ GitHub Actions-Syntax für Datenbanken und Service-Container

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

Expand Down Expand Up @@ -356,7 +355,7 @@ Zuordnungen
+-----------------------------------------------+-----------------------------------------------+
| ``actions/upload-artifact@v2`` | ``artifacts`` |
+-----------------------------------------------+-----------------------------------------------+
| ``actions/cache@v2`` | ``cache`` |
| ``actions/cache@v4`` | ``cache`` |
+-----------------------------------------------+-----------------------------------------------+
| ``actions/download-artifact@v2`` | ``dependencies`` |
+-----------------------------------------------+-----------------------------------------------+
Expand Down
Loading
Loading