Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
python-version: [3.9, "3.10", 3.11, 3.12, 3.13, 3.14]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ might need them.

$ pip3 install gitprivacy

_Note: `git-privacy` requires Python version 3.6 or later and Git version 2.22.0 or later._
_Note: `git-privacy` requires Python version 3.9 or later and Git version 2.22.0 or later._


## Getting Started
Expand Down
12 changes: 6 additions & 6 deletions gitprivacy/gitprivacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import click
import git # type: ignore
import os
import importlib.resources
import shutil
import stat
import sys

from datetime import datetime, timezone
from pkg_resources import resource_stream, resource_string
from typing import Optional, TextIO, Tuple


Expand Down Expand Up @@ -178,15 +178,16 @@ def get_template_dir(repo: git.Repo) -> str:
return templatedir


def copy_hook(git_path: str, hook: str, ) -> None:
def copy_hook(git_path: str, hook: str) -> None:
hookdir = os.path.join(git_path, "hooks")
if not os.path.exists(hookdir):
os.mkdir(hookdir)
hook_fn = os.path.join(hookdir, hook)
hook_res = importlib.resources.files('gitprivacy.resources.hooks') / hook
try:
dst = open(hook_fn, "xb")
except FileExistsError:
hook_txt = resource_string('gitprivacy.resources.hooks', hook).decode()
hook_txt = hook_res.read_text(encoding='utf-8')
with open(hook_fn, "r") as f:
if f.read() == hook_txt:
print(f"{hook} hook is already installed at {hook_fn}.")
Expand All @@ -196,13 +197,12 @@ def copy_hook(git_path: str, hook: str, ) -> None:
f"hook:\n\n{hook_txt}")
return
else:
with resource_stream('gitprivacy.resources.hooks', hook) as src, dst:
shutil.copyfileobj(src, dst) # type: ignore
with hook_res.open('rb') as src, dst:
shutil.copyfileobj(src, dst)
os.chmod(hook_fn, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP |
stat.S_IROTH | stat.S_IXOTH) # mode 755
print("Installed {} hook".format(hook))


@cli.command('log')
@click.option('-r', '--revision-range', required=False, default='HEAD',
help="Show only commits in the specified revision range.")
Expand Down
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
license="BSD",
packages=find_packages(exclude=('tests', 'docs')),
include_package_data=True,
python_requires='>=3.6',
python_requires='>=3.9',
install_requires=[
'click>=7',
'gitpython',
Expand All @@ -33,11 +33,12 @@
"Topic :: Software Development :: Version Control :: Git",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
],
Expand Down
6 changes: 4 additions & 2 deletions tests/test_gitprivacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,10 @@ def test_commitdateupdate(self):


def load_exported_commit(self, path):
from pkg_resources import resource_stream
with resource_stream('tests', path) as input_fd:
from importlib.resources import files

resource_path = files('tests') / path
with resource_path.open('rb') as input_fd:
res, stdout, stderr = self.git.fast_import(
"--force", # discard existing commits
istream=input_fd,
Expand Down