git-spellcheck 0.1.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Asad Khalid
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.4
2
+ Name: git-spellcheck
3
+ Version: 0.1.0
4
+ Summary: Interactive Git commit message spellchecker
5
+ Home-page: https://github.com/Asad-K2025/git-spellcheck
6
+ Author: Asad Khalid
7
+ License: MIT
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: pyspellchecker>=0.7.0
15
+ Dynamic: author
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: license
21
+ Dynamic: license-file
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ # Git Spellcheck
27
+
28
+ Spelling mistakes in commit messages can easily occur, especially when using the CLI with `git commit -m`.
29
+
30
+ This tool aims to be quick and easy to set up, while also being lightweight. It automatically checks for spelling errors
31
+ in commit message and provides an option to interactively fix them without rewriting the entire message.
32
+ ## How To Use
33
+
34
+ 1. Install from PyPi:
35
+ ```bash
36
+ pip install git-spellcheck
37
+ ```
38
+ 2. Either setup:
39
+
40
+ **Global installation** for all repositories:
41
+
42
+ ```bash
43
+ git-spellcheck --install-global
44
+ ```
45
+
46
+ OR **local installation** only for current repository
47
+ ```bash
48
+ git-spellcheck --install-local
49
+ ```
50
+
51
+ 3. Commit as usual
52
+ ```bash
53
+ git commit -m "Fix autentcation bug in login modul"
54
+ ```
55
+ If spelling mistakes are found, you'll see:
56
+ ```
57
+ Git Spellcheck Warning:
58
+ - "autentcation" (suggestions: authentication)
59
+ - "modul" (suggestions: module, moduli, model, mosul, mogul, modal)
60
+ Run `git-spellcheck --fix` to amend.```
61
+
62
+ 4. Fix last commit interactively
63
+ ```bash
64
+ git-spellcheck --fix
65
+ ```
66
+ Interactive mode lets you:
67
+ - See spelling suggestions
68
+ - Enter replacements
69
+ - Automatically amend your last commit
70
+
71
+ ```
72
+ - "autentcation"
73
+ suggestions: authentication
74
+ Enter replacement (or press ENTER to skip):
75
+ ```
76
+ 5. The commit is now ready to be pushed.
77
+
78
+
79
+ ## Behavior
80
+
81
+ When a commit is made, the subject line is scanned for misspelled words using `pyspellchecker`. If issues are found, suggestions are displayed.
82
+
83
+ The interactive mode allows reviewing each misspelled word and optionally replacing it, automatically amending the last commit with the corrected message.
84
+
85
+ Adding `[skip-spell]` to a commit message bypasses the spellcheck. The flag is automatically removed before finalising
86
+ the commit.
87
+
88
+ ## Requirements
89
+
90
+ - Python 3.7 or higher
91
+ - Git
@@ -0,0 +1,66 @@
1
+ # Git Spellcheck
2
+
3
+ Spelling mistakes in commit messages can easily occur, especially when using the CLI with `git commit -m`.
4
+
5
+ This tool aims to be quick and easy to set up, while also being lightweight. It automatically checks for spelling errors
6
+ in commit message and provides an option to interactively fix them without rewriting the entire message.
7
+ ## How To Use
8
+
9
+ 1. Install from PyPi:
10
+ ```bash
11
+ pip install git-spellcheck
12
+ ```
13
+ 2. Either setup:
14
+
15
+ **Global installation** for all repositories:
16
+
17
+ ```bash
18
+ git-spellcheck --install-global
19
+ ```
20
+
21
+ OR **local installation** only for current repository
22
+ ```bash
23
+ git-spellcheck --install-local
24
+ ```
25
+
26
+ 3. Commit as usual
27
+ ```bash
28
+ git commit -m "Fix autentcation bug in login modul"
29
+ ```
30
+ If spelling mistakes are found, you'll see:
31
+ ```
32
+ Git Spellcheck Warning:
33
+ - "autentcation" (suggestions: authentication)
34
+ - "modul" (suggestions: module, moduli, model, mosul, mogul, modal)
35
+ Run `git-spellcheck --fix` to amend.```
36
+
37
+ 4. Fix last commit interactively
38
+ ```bash
39
+ git-spellcheck --fix
40
+ ```
41
+ Interactive mode lets you:
42
+ - See spelling suggestions
43
+ - Enter replacements
44
+ - Automatically amend your last commit
45
+
46
+ ```
47
+ - "autentcation"
48
+ suggestions: authentication
49
+ Enter replacement (or press ENTER to skip):
50
+ ```
51
+ 5. The commit is now ready to be pushed.
52
+
53
+
54
+ ## Behavior
55
+
56
+ When a commit is made, the subject line is scanned for misspelled words using `pyspellchecker`. If issues are found, suggestions are displayed.
57
+
58
+ The interactive mode allows reviewing each misspelled word and optionally replacing it, automatically amending the last commit with the corrected message.
59
+
60
+ Adding `[skip-spell]` to a commit message bypasses the spellcheck. The flag is automatically removed before finalising
61
+ the commit.
62
+
63
+ ## Requirements
64
+
65
+ - Python 3.7 or higher
66
+ - Git
File without changes
@@ -0,0 +1,168 @@
1
+ #!/usr/bin/env python3
2
+ import sys
3
+ import re
4
+ import platform
5
+ import subprocess
6
+ import os
7
+ from pathlib import Path
8
+ from spellchecker import SpellChecker
9
+
10
+ BYPASS_FLAG = "[skip-spell]"
11
+
12
+
13
+ def run_commit_msg_hook(commit_msg_file: str):
14
+ spell = SpellChecker()
15
+ commit_msg_path = Path(commit_msg_file)
16
+
17
+ message = commit_msg_path.read_text(encoding="utf-8")
18
+
19
+ if BYPASS_FLAG in message:
20
+ cleaned = message.replace(BYPASS_FLAG, "").strip()
21
+ commit_msg_path.write_text(cleaned, encoding="utf-8")
22
+ return 0
23
+
24
+ subject = message.split("\n")[0]
25
+ words = re.findall(r"\b[a-zA-Z']+\b", subject)
26
+ misspelled = list(spell.unknown(words))
27
+
28
+ if not misspelled:
29
+ return 0
30
+
31
+ print("\nGit Spellcheck Warning:")
32
+ for word in misspelled:
33
+ candidates = spell.candidates(word)
34
+ suggestions = list(candidates)[:6] if candidates else []
35
+ if suggestions:
36
+ print(f' - "{word}" (suggestions: {", ".join(suggestions)})')
37
+ else:
38
+ print(f' - "{word}" has no suggestions')
39
+
40
+ print("Run `git-spellcheck --fix` to amend.\n")
41
+
42
+ return 0
43
+
44
+
45
+ def fix_last_commit():
46
+ spell = SpellChecker()
47
+
48
+ result = subprocess.run(
49
+ ["git", "log", "-1", "--pretty=%B"],
50
+ capture_output=True,
51
+ text=True
52
+ )
53
+
54
+ print("""---------------------------------
55
+ Git Spellcheck - Interactive Mode
56
+ ---------------------------------""")
57
+ print()
58
+
59
+ if result.returncode != 0:
60
+ print("Failed to retrieve last commit message. Exiting Git Spellcheck.")
61
+ return 1
62
+
63
+ message = result.stdout
64
+ lines = message.split("\n")
65
+ subject = lines[0]
66
+
67
+ words = re.findall(r"\b[a-zA-Z']+\b", subject)
68
+ misspelled = list(spell.unknown(words))
69
+
70
+ if not misspelled:
71
+ print("No spelling issues found. Exiting Git Spellcheck.")
72
+ return 0
73
+
74
+ updated_subject = subject
75
+
76
+ for word in misspelled:
77
+ print("-" * 20)
78
+ print(f' - "{word}"')
79
+ candidates = spell.candidates(word)
80
+ suggestions = list(candidates)[:6] if candidates else []
81
+
82
+ if suggestions:
83
+ print(f" suggestions: {', '.join(suggestions)}")
84
+ else:
85
+ print(" no suggestions")
86
+
87
+ replacement = input("Enter replacement (or press ENTER to skip): ").strip()
88
+ print("-" * 20)
89
+ print()
90
+
91
+ if replacement:
92
+ def replace_match(match):
93
+ original = match.group(0)
94
+
95
+ if original.isupper():
96
+ return replacement.upper()
97
+ elif original[0].isupper():
98
+ return replacement.capitalize()
99
+ else:
100
+ return replacement
101
+
102
+ updated_subject = re.sub(
103
+ rf"\b{re.escape(word)}\b",
104
+ replace_match,
105
+ updated_subject,
106
+ flags=re.IGNORECASE
107
+ )
108
+
109
+ if updated_subject == subject:
110
+ print("No changes made.")
111
+ return 0
112
+
113
+ lines[0] = updated_subject
114
+ new_message = "\n".join(lines)
115
+
116
+ subprocess.run(["git", "commit", "--amend", "-m", new_message])
117
+ return 0
118
+
119
+
120
+ def install_hook(global_install=False):
121
+ if platform.system() == "Windows":
122
+ hooks_path = Path(os.environ["USERPROFILE"]) / ".git-hooks"
123
+ else:
124
+ hooks_path = Path.home() / ".git-hooks"
125
+
126
+ if global_install:
127
+ hooks_path.mkdir(exist_ok=True)
128
+ hook_file = hooks_path / "commit-msg"
129
+ hook_file.write_text("""#!/bin/sh
130
+ git-spellcheck "$1"
131
+ """)
132
+ hook_file.chmod(0o755)
133
+ subprocess.run(["git", "config", "--global", "core.hooksPath", str(hooks_path)])
134
+ print(f"Global commit-msg hook installed in {hooks_path}")
135
+ else:
136
+ repo_hooks = Path(".git/hooks")
137
+ if not repo_hooks.exists():
138
+ print("Not a git repository.")
139
+ return
140
+ repo_hooks.mkdir(exist_ok=True)
141
+ hook_file = repo_hooks / "commit-msg"
142
+ hook_file.write_text("""#!/bin/sh
143
+ git-spellcheck "$1"
144
+ """)
145
+ hook_file.chmod(0o755)
146
+ print(f"commit-msg hook installed in {repo_hooks}")
147
+
148
+
149
+ def main():
150
+ import argparse
151
+ parser = argparse.ArgumentParser(description="Interactive Git commit message spellchecker")
152
+ parser.add_argument("commit_msg_file", nargs="?", help=argparse.SUPPRESS)
153
+ parser.add_argument("--install-global", action="store_true", help="Install commit-msg hook globally")
154
+ parser.add_argument("--install-local", action="store_true", help="Install commit-msg hook locally in current repo")
155
+ parser.add_argument("--fix", action="store_true", help="Interactively fix last commit")
156
+ args = parser.parse_args()
157
+
158
+ if args.install_global:
159
+ install_hook(global_install=True)
160
+ elif args.install_local:
161
+ install_hook(global_install=False)
162
+ elif args.commit_msg_file:
163
+ sys.exit(run_commit_msg_hook(args.commit_msg_file))
164
+ elif args.fix:
165
+ sys.exit(fix_last_commit())
166
+ else:
167
+ parser.print_help()
168
+ sys.exit(1)
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.4
2
+ Name: git-spellcheck
3
+ Version: 0.1.0
4
+ Summary: Interactive Git commit message spellchecker
5
+ Home-page: https://github.com/Asad-K2025/git-spellcheck
6
+ Author: Asad Khalid
7
+ License: MIT
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: pyspellchecker>=0.7.0
15
+ Dynamic: author
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: license
21
+ Dynamic: license-file
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ # Git Spellcheck
27
+
28
+ Spelling mistakes in commit messages can easily occur, especially when using the CLI with `git commit -m`.
29
+
30
+ This tool aims to be quick and easy to set up, while also being lightweight. It automatically checks for spelling errors
31
+ in commit message and provides an option to interactively fix them without rewriting the entire message.
32
+ ## How To Use
33
+
34
+ 1. Install from PyPi:
35
+ ```bash
36
+ pip install git-spellcheck
37
+ ```
38
+ 2. Either setup:
39
+
40
+ **Global installation** for all repositories:
41
+
42
+ ```bash
43
+ git-spellcheck --install-global
44
+ ```
45
+
46
+ OR **local installation** only for current repository
47
+ ```bash
48
+ git-spellcheck --install-local
49
+ ```
50
+
51
+ 3. Commit as usual
52
+ ```bash
53
+ git commit -m "Fix autentcation bug in login modul"
54
+ ```
55
+ If spelling mistakes are found, you'll see:
56
+ ```
57
+ Git Spellcheck Warning:
58
+ - "autentcation" (suggestions: authentication)
59
+ - "modul" (suggestions: module, moduli, model, mosul, mogul, modal)
60
+ Run `git-spellcheck --fix` to amend.```
61
+
62
+ 4. Fix last commit interactively
63
+ ```bash
64
+ git-spellcheck --fix
65
+ ```
66
+ Interactive mode lets you:
67
+ - See spelling suggestions
68
+ - Enter replacements
69
+ - Automatically amend your last commit
70
+
71
+ ```
72
+ - "autentcation"
73
+ suggestions: authentication
74
+ Enter replacement (or press ENTER to skip):
75
+ ```
76
+ 5. The commit is now ready to be pushed.
77
+
78
+
79
+ ## Behavior
80
+
81
+ When a commit is made, the subject line is scanned for misspelled words using `pyspellchecker`. If issues are found, suggestions are displayed.
82
+
83
+ The interactive mode allows reviewing each misspelled word and optionally replacing it, automatically amending the last commit with the corrected message.
84
+
85
+ Adding `[skip-spell]` to a commit message bypasses the spellcheck. The flag is automatically removed before finalising
86
+ the commit.
87
+
88
+ ## Requirements
89
+
90
+ - Python 3.7 or higher
91
+ - Git
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ git_spellcheck/__init__.py
6
+ git_spellcheck/cli.py
7
+ git_spellcheck.egg-info/PKG-INFO
8
+ git_spellcheck.egg-info/SOURCES.txt
9
+ git_spellcheck.egg-info/dependency_links.txt
10
+ git_spellcheck.egg-info/entry_points.txt
11
+ git_spellcheck.egg-info/requires.txt
12
+ git_spellcheck.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ git-spellcheck = git_spellcheck.cli:main
@@ -0,0 +1 @@
1
+ pyspellchecker>=0.7.0
@@ -0,0 +1 @@
1
+ git_spellcheck
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,27 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="git-spellcheck",
5
+ version="0.1.0",
6
+ license="MIT",
7
+ packages=find_packages(),
8
+ install_requires=[
9
+ "pyspellchecker>=0.7.0"
10
+ ],
11
+ entry_points={
12
+ "console_scripts": [
13
+ "git-spellcheck=git_spellcheck.cli:main"
14
+ ]
15
+ },
16
+ python_requires=">=3.7",
17
+ description="Interactive Git commit message spellchecker",
18
+ long_description=open("README.md").read(),
19
+ long_description_content_type="text/markdown",
20
+ author="Asad Khalid",
21
+ url="https://github.com/Asad-K2025/git-spellcheck",
22
+ classifiers=[
23
+ "Programming Language :: Python :: 3",
24
+ "License :: OSI Approved :: MIT License",
25
+ "Operating System :: OS Independent",
26
+ ],
27
+ )