Skip to content

Commit

Permalink
alternative
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Feb 15, 2024
1 parent 58fe536 commit 9b0ad0f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
# use black formatting
- id: ruff-format
name: Black by Ruff
# basic check
- id: ruff
name: Ruff check
args: ["--fix"]
# use black formatting
- id: ruff-format
name: Black by Ruff
19 changes: 3 additions & 16 deletions cachier/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# Copyright (c) 2024, Jirka Borovec <***@gmail.com>

import os
import subprocess

_PATH_HERE = os.path.dirname(__file__)
_PATH_VERSION = os.path.join(_PATH_HERE, "version.info")
Expand All @@ -17,22 +16,10 @@


def _get_git_sha() -> str:
try:
os.chdir(_PATH_HERE)

# Run the git command to get the SHA of the current commit.
# The --short flag gets the abbreviated SHA.
git_sha = subprocess.check_output(
["git", "rev-parse", "--short", "HEAD"], stderr=subprocess.DEVNULL
).strip()

# Decode the output from bytes to a string.
return git_sha.decode("utf-8")
from subprocess import check_output, DEVNULL

except (subprocess.CalledProcessError, FileNotFoundError):
# CalledProcessError - raised if git returns a non-zero error code
# FileNotFoundError - raised if git is not installed
return ""
out = check_output(["git", "rev-parse", "--short", "HEAD"], stderr=DEVNULL) # noqa: S603, S607
return out.decode("utf-8").strip()


if not _RELEASING_PROCESS:
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ lint.ignore-init-module-imports = true
lint.unfixable = ["F401"]

[tool.ruff.lint.per-file-ignores]
"cachier/_version.py" = ["S603", "S607"] # todo

"tests/**" = ["S101", "S311", "S105", "S603"]

#[tool.ruff.pydocstyle]
Expand Down

0 comments on commit 9b0ad0f

Please sign in to comment.