diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..93c1a28e --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,7 @@ +# Have a look at +# https://stackoverflow.com/questions/34957237/can-i-configure-git-blame-to-always-ignore-certain-commits-want-to-fix-git-blam/57129540#57129540 +# https://akrabat.com/ignoring-revisions-with-git-blame/ +# https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view + +# Run code through black for formatting +c3b39ea3d4488c62d4a39c6be5b7ca5fdf6cda84 \ No newline at end of file diff --git a/README.md b/README.md index f0b119d6..58674ff1 100644 --- a/README.md +++ b/README.md @@ -120,3 +120,23 @@ python -m pip install pip-tools ``` more info available at: https://github.com/jazzband/pip-tools/ + + +# Ignoring large reformattings with git blame + +The commits listed in `.git-blame-ignore-revs` are automatically ignored in github blame view +(https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view). +This feature is meant to ignore commits that just introduced reformatting, and maintain the logical +contributions of each line. + +You can make use of the `.git-blame-ignore-revs` file locally by passing it as an argument to the +blame command: +``` +git blame --ignore-revs-file .git-blame-ignore-revs ... +``` +or by adding it to your local git configurations: +``` +git config --local blame.ignoreRevsFile .git-blame-ignore-revs +``` +Note that this should be done for per-project, as some projects may lack the `.git-blame-ignore-revs` +file, and in this case `git blame` would return an error. \ No newline at end of file diff --git a/tox.ini b/tox.ini index 4abc022d..d420741a 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] -envlist = bandit, docs, flake8, mypy, py311 +envlist = bandit, docs, flake8, black, mypy, py311 ignore_base_python_conflict = True [testenv] @@ -30,6 +30,12 @@ skip_install = true deps = flake8 commands = flake8 +[testenv:black] +basepython = python3 +deps = black +commands = black --line-length 100 --check . \ + --extend-exclude="dev_scripts\/|freshmaker\/migrations\/|\.tox\/|build\/|__pycache__|scripts\/print_handlers_md\.py|\.copr\/|\.env" + [testenv:mypy] description = type check deps = @@ -51,7 +57,7 @@ ignore_outcome = True [flake8] skip_install = true -ignore = E501,E731,W503,W504 +ignore = E501,E731,W503,W504,E203 exclude = dev_scripts/*,freshmaker/migrations/*,.tox/*,build/*,__pycache__,scripts/print_handlers_md.py,.copr/*,.env [testenv:docs]