Skip to content
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

Pre commit python #11004

Merged
merged 10 commits into from
Nov 14, 2022
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
IndentCaseLabels: false
DerivePointerAlignment: false
ReflowComments: false
SpaceAfterTemplateKeyword: false
SpacesBeforeTrailingComments: 1
# StatementMacros don't require a trailing semicolon.
Expand Down
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@

# Treat serato test data as binary
*.octet-stream binary

# shell scripts will always have LF line endings on checkout.
*.sh text eol=lf
2 changes: 2 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
run: |
git diff-index -p HEAD > "${PATCH_FILE}"
[ -s "${PATCH_FILE}" ] && echo "UPLOAD_PATCH_FILE=${PATCH_FILE}" >> "${GITHUB_ENV}"
shell: bash
env:
PATCH_FILE: pre-commit.patch

Expand All @@ -70,4 +71,5 @@ jobs:

# AppStream metadata has been generated/updated by a pre-commit hook
- name: "Validate AppStream metadata"
if: runner.os == 'Linux'
run: appstreamcli validate res/linux/org.mixxx.Mixxx.metainfo.xml
14 changes: 8 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,22 @@ repos:
- id: clang-format
name: clang-format
description: "Run clang-format in two passes (reformat, then break long lines)"
entry: tools/clang_format.py
entry: python tools/clang_format.py
require_serial: true
stages:
- commit
- manual
language: python
additional_dependencies:
- clang-format==14.0.6
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|m|mm|proto|vert)$
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
files: ^tools/.*$
- repo: https://gitlab.com/pycqa/flake8
rev: "3.9.2"
rev: "5.0.4"
hooks:
- id: flake8
files: ^tools/.*$
Expand All @@ -114,7 +116,7 @@ repos:
- id: qsscheck
name: qsscheck
description: Run qsscheck to detect broken QSS.
entry: ./tools/qsscheck.py
entry: python tools/qsscheck.py
args: [.]
pass_filenames: false
language: python
Expand All @@ -128,19 +130,19 @@ repos:
- id: changelog
name: changelog
description: Add missing links to changelog.
entry: ./tools/changelog.py
entry: python tools/changelog.py
language: python
types: [text]
files: ^CHANGELOG.md$
- id: metainfo
name: metainfo
description: Update AppStream metainfo releases from CHANGELOG.md.
entry: ./tools/update_metainfo.py
entry: python tools/update_metainfo.py
pass_filenames: false
language: python
additional_dependencies:
- beautifulsoup4==4.11.1
- lxml==4.9.1
- Markdown==3.3.4
- Markdown==3.4.1
types: [text]
files: ^(CHANGELOG\.md|res/linux/org\.mixxx\.Mixxx\.metainfo.xml)$
2 changes: 1 addition & 1 deletion tools/githelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_toplevel_path() -> str:

cmd = ["git", "rev-parse", "--show-toplevel"]
logger.debug("Executing: %r", cmd)
return subprocess.check_output(cmd, text=True).strip()
return os.path.normpath(subprocess.check_output(cmd, text=True).strip())


def get_moved_files(
Expand Down
2 changes: 1 addition & 1 deletion tools/update_metainfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def main(argv=None):
.strip()
)

with open(changelog_path, mode="r") as fp:
with open(changelog_path, mode="r", encoding="utf-8") as fp:
for release in parse_changelog(
fp.read(), development_release_date=parent_changelog_change_date
):
Expand Down