git-notes-hooks 0.1.1__tar.gz → 0.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: git-notes-hooks
3
- Version: 0.1.1
3
+ Version: 0.1.6
4
4
  Summary: Automatic Git hooks to keep refs/notes/* synchronized across all remotes on push and pull
5
- Author-email: isaim0011 <git-notes@open-source.dev>
5
+ Author-email: Bimo <i.s41m0011@gmail.com>
6
6
  License: MIT OR Apache-2.0
7
7
  Project-URL: Homepage, https://github.com/isaim0011/git-notes
8
8
  Project-URL: Repository, https://github.com/isaim0011/git-notes
@@ -1,54 +1,58 @@
1
- [build-system]
2
- requires = ["setuptools>=68", "wheel"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "git-notes-hooks"
7
- version = "0.1.1"
8
- description = "Automatic Git hooks to keep refs/notes/* synchronized across all remotes on push and pull"
9
- readme = "README.md"
10
- requires-python = ">=3.11"
11
- license = { text = "MIT OR Apache-2.0" }
12
- authors = [
13
- { name = "isaim0011", email = "git-notes@open-source.dev" }
14
- ]
15
- keywords = ["git", "git-notes", "git-hooks", "code-review", "decentralized", "developer-tools"]
16
- classifiers = [
17
- "Development Status :: 4 - Beta",
18
- "Environment :: Console",
19
- "Intended Audience :: Developers",
20
- "License :: OSI Approved :: MIT License",
21
- "License :: OSI Approved :: Apache Software License",
22
- "Operating System :: OS Independent",
23
- "Programming Language :: Python :: 3",
24
- "Programming Language :: Python :: 3.11",
25
- "Programming Language :: Python :: 3.12",
26
- "Programming Language :: Python :: 3.13",
27
- "Programming Language :: Python :: 3.14",
28
- "Topic :: Software Development :: Version Control :: Git",
29
- ]
30
- dependencies = [
31
- "click>=8.1",
32
- "rich>=13.0",
33
- ]
34
-
35
- [project.urls]
36
- Homepage = "https://github.com/isaim0011/git-notes"
37
- Repository = "https://github.com/isaim0011/git-notes"
38
- Issues = "https://github.com/isaim0011/git-notes/issues"
39
- Documentation = "https://github.com/isaim0011/git-notes#readme"
40
- Changelog = "https://github.com/isaim0011/git-notes/blob/main/docs/CHANGELOG.md"
41
-
42
- [project.scripts]
43
- git-notes-hooks = "gn_hooks.cli:main"
44
-
45
- [project.optional-dependencies]
46
- dev = [
47
- "pytest>=8",
48
- "pytest-mock",
49
- "ruff",
50
- ]
51
-
52
- [tool.setuptools.packages.find]
53
- where = [".."]
54
- include = ["gn_hooks*"]
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "git-notes-hooks"
7
+ version = "0.1.6"
8
+ description = "Automatic Git hooks to keep refs/notes/* synchronized across all remotes on push and pull"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = { text = "MIT OR Apache-2.0" }
12
+ authors = [
13
+ { name = "Bimo", email = "i.s41m0011@gmail.com" }
14
+ ]
15
+ keywords = ["git", "git-notes", "git-hooks", "code-review", "decentralized", "developer-tools"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: MIT License",
21
+ "License :: OSI Approved :: Apache Software License",
22
+ "Operating System :: OS Independent",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Programming Language :: Python :: 3.14",
28
+ "Topic :: Software Development :: Version Control :: Git",
29
+ ]
30
+ dependencies = [
31
+ "click>=8.1",
32
+ "rich>=13.0",
33
+ ]
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/isaim0011/git-notes"
37
+ Repository = "https://github.com/isaim0011/git-notes"
38
+ Issues = "https://github.com/isaim0011/git-notes/issues"
39
+ Documentation = "https://github.com/isaim0011/git-notes#readme"
40
+ Changelog = "https://github.com/isaim0011/git-notes/blob/main/docs/CHANGELOG.md"
41
+
42
+ [project.scripts]
43
+ git-notes-hooks = "gn_hooks.cli:main"
44
+
45
+ [project.optional-dependencies]
46
+ dev = [
47
+ "pytest>=8",
48
+ "pytest-mock",
49
+ "ruff",
50
+ ]
51
+
52
+ [tool.setuptools.packages.find]
53
+ where = [".."]
54
+ include = ["gn_hooks*"]
55
+
56
+ [tool.pytest.ini_options]
57
+ pythonpath = ["."]
58
+ testpaths = ["tests"]
@@ -0,0 +1,94 @@
1
+ from pathlib import Path
2
+ import pytest
3
+
4
+ from gn_hooks.install import find_git_root
5
+
6
+
7
+ def test_find_git_root_at_repo_root(tmp_path: Path):
8
+ """find_git_root returns the path itself when .git dir is directly in path."""
9
+ git_dir = tmp_path / ".git"
10
+ git_dir.mkdir()
11
+
12
+ result = find_git_root(tmp_path)
13
+ assert result == tmp_path.resolve()
14
+
15
+
16
+ def test_find_git_root_from_nested_subdir(tmp_path: Path):
17
+ """find_git_root walks up directory tree from a nested subdirectory to find .git dir."""
18
+ git_dir = tmp_path / ".git"
19
+ git_dir.mkdir()
20
+
21
+ nested_dir = tmp_path / "sub1" / "sub2" / "sub3"
22
+ nested_dir.mkdir(parents=True)
23
+
24
+ result = find_git_root(nested_dir)
25
+ assert result == tmp_path.resolve()
26
+
27
+
28
+ def test_find_git_root_from_file_path(tmp_path: Path):
29
+ """find_git_root works when passed a file path inside a repository."""
30
+ git_dir = tmp_path / ".git"
31
+ git_dir.mkdir()
32
+
33
+ sub_dir = tmp_path / "src"
34
+ sub_dir.mkdir()
35
+ file_path = sub_dir / "main.py"
36
+ file_path.write_text("print('hello')")
37
+
38
+ result = find_git_root(file_path)
39
+ assert result == tmp_path.resolve()
40
+
41
+
42
+ def test_find_git_root_with_relative_path(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
43
+ """find_git_root handles relative paths correctly by resolving them."""
44
+ git_dir = tmp_path / ".git"
45
+ git_dir.mkdir()
46
+
47
+ sub_dir = tmp_path / "sub"
48
+ sub_dir.mkdir()
49
+
50
+ monkeypatch.chdir(sub_dir)
51
+ result = find_git_root(Path("."))
52
+ assert result == tmp_path.resolve()
53
+
54
+
55
+ def test_find_git_root_when_git_is_a_file(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
56
+ """find_git_root ignores .git if it is a file instead of a directory."""
57
+ resolved_tmp = tmp_path.resolve()
58
+ sub_dir = resolved_tmp / "sub"
59
+ sub_dir.mkdir()
60
+ git_file = sub_dir / ".git"
61
+ git_file.write_text("gitdir: /path/to/git")
62
+
63
+ # Stop search loop at resolved_tmp to isolate test from outer directory tree
64
+ original_parent_fget = Path.parent.fget
65
+
66
+ def custom_parent(self):
67
+ if self == resolved_tmp:
68
+ return self
69
+ return original_parent_fget(self)
70
+
71
+ monkeypatch.setattr(Path, "parent", property(custom_parent))
72
+
73
+ with pytest.raises(FileNotFoundError, match="Not a git repository"):
74
+ find_git_root(sub_dir)
75
+
76
+
77
+ def test_find_git_root_not_found_raises_file_not_found_error(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
78
+ """find_git_root raises FileNotFoundError when no parent directory contains a .git directory."""
79
+ resolved_tmp = tmp_path.resolve()
80
+ no_git_dir = resolved_tmp / "no_git_dir"
81
+ no_git_dir.mkdir()
82
+
83
+ # Stop search loop at resolved_tmp to guarantee clean test isolation
84
+ original_parent_fget = Path.parent.fget
85
+
86
+ def custom_parent(self):
87
+ if self == resolved_tmp:
88
+ return self
89
+ return original_parent_fget(self)
90
+
91
+ monkeypatch.setattr(Path, "parent", property(custom_parent))
92
+
93
+ with pytest.raises(FileNotFoundError, match="Not a git repository"):
94
+ find_git_root(no_git_dir)