tgit 0.8.0__tar.gz → 0.9.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.
- tgit-0.9.0/.python-version +1 -0
- {tgit-0.8.0 → tgit-0.9.0}/PKG-INFO +2 -2
- {tgit-0.8.0 → tgit-0.9.0}/pyproject.toml +3 -3
- {tgit-0.8.0 → tgit-0.9.0}/requirements-dev.lock +2 -2
- {tgit-0.8.0 → tgit-0.9.0}/requirements.lock +1 -1
- tgit-0.9.0/tgit/add.py +13 -0
- {tgit-0.8.0 → tgit-0.9.0}/tgit/cli.py +2 -0
- {tgit-0.8.0 → tgit-0.9.0}/tgit/commit.py +5 -1
- {tgit-0.8.0 → tgit-0.9.0}/tgit/utils.py +9 -0
- {tgit-0.8.0 → tgit-0.9.0}/tgit/version.py +87 -59
- tgit-0.8.0/.python-version +0 -1
- {tgit-0.8.0 → tgit-0.9.0}/.gitignore +0 -0
- {tgit-0.8.0 → tgit-0.9.0}/.tgit.yml +0 -0
- {tgit-0.8.0 → tgit-0.9.0}/.vscode/settings.json +0 -0
- {tgit-0.8.0 → tgit-0.9.0}/CHANGELOG.md +0 -0
- {tgit-0.8.0 → tgit-0.9.0}/README.md +0 -0
- {tgit-0.8.0 → tgit-0.9.0}/scripts/publish.sh +0 -0
- {tgit-0.8.0 → tgit-0.9.0}/tgit/__init__.py +0 -0
- {tgit-0.8.0 → tgit-0.9.0}/tgit/changelog.py +0 -0
- {tgit-0.8.0 → tgit-0.9.0}/tgit/settings.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12.6
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: tgit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
4
|
Summary: Tool for Git Interaction Temptation (tgit): An elegant CLI tool that simplifies and streamlines your Git workflow, making version control a breeze.
|
|
5
5
|
Author-email: Jannchie <jannchie@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -15,7 +15,7 @@ Classifier: Typing :: Typed
|
|
|
15
15
|
Requires-Python: >=3.11
|
|
16
16
|
Requires-Dist: gitpython>=3.1.43
|
|
17
17
|
Requires-Dist: inquirer>=3.4.0
|
|
18
|
-
Requires-Dist: openai>=1.
|
|
18
|
+
Requires-Dist: openai>=1.52.0
|
|
19
19
|
Requires-Dist: pyyaml>=6.0.2
|
|
20
20
|
Requires-Dist: rich>=13.9.2
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "tgit"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.9.0"
|
|
4
4
|
description = "Tool for Git Interaction Temptation (tgit): An elegant CLI tool that simplifies and streamlines your Git workflow, making version control a breeze."
|
|
5
5
|
authors = [{ name = "Jannchie", email = "jannchie@gmail.com" }]
|
|
6
6
|
dependencies = [
|
|
@@ -8,7 +8,7 @@ dependencies = [
|
|
|
8
8
|
"pyyaml>=6.0.2",
|
|
9
9
|
"inquirer>=3.4.0",
|
|
10
10
|
"gitpython>=3.1.43",
|
|
11
|
-
"openai>=1.
|
|
11
|
+
"openai>=1.52.0",
|
|
12
12
|
]
|
|
13
13
|
readme = { content-type = "text/markdown", file = "README.md" }
|
|
14
14
|
requires-python = ">= 3.11"
|
|
@@ -30,7 +30,7 @@ build-backend = "hatchling.build"
|
|
|
30
30
|
|
|
31
31
|
[tool.rye]
|
|
32
32
|
managed = true
|
|
33
|
-
dev-dependencies = ["black>=24.
|
|
33
|
+
dev-dependencies = ["black>=24.10.0", "isort>=5.13.2"]
|
|
34
34
|
|
|
35
35
|
[tool.black]
|
|
36
36
|
line-length = 160
|
|
@@ -17,7 +17,7 @@ ansicon==1.89.0
|
|
|
17
17
|
anyio==4.6.0
|
|
18
18
|
# via httpx
|
|
19
19
|
# via openai
|
|
20
|
-
black==24.
|
|
20
|
+
black==24.10.0
|
|
21
21
|
blessed==1.20.0
|
|
22
22
|
# via inquirer
|
|
23
23
|
certifi==2024.8.30
|
|
@@ -58,7 +58,7 @@ mdurl==0.1.2
|
|
|
58
58
|
# via markdown-it-py
|
|
59
59
|
mypy-extensions==1.0.0
|
|
60
60
|
# via black
|
|
61
|
-
openai==1.
|
|
61
|
+
openai==1.52.0
|
|
62
62
|
# via tgit
|
|
63
63
|
packaging==24.1
|
|
64
64
|
# via black
|
tgit-0.9.0/tgit/add.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from tgit.utils import simple_run_command
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def define_add_parser(subparsers):
|
|
5
|
+
parser_add = subparsers.add_parser("add", help="same as git add")
|
|
6
|
+
parser_add.add_argument("files", help="files to add", nargs="*")
|
|
7
|
+
parser_add.set_defaults(func=handle_add)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def handle_add(args):
|
|
11
|
+
files = " ".join(args.files)
|
|
12
|
+
command = f"git add {files}"
|
|
13
|
+
simple_run_command(command)
|
|
@@ -4,6 +4,7 @@ import importlib.metadata
|
|
|
4
4
|
import rich
|
|
5
5
|
import rich.traceback
|
|
6
6
|
|
|
7
|
+
from tgit.add import define_add_parser
|
|
7
8
|
from tgit.changelog import define_changelog_parser
|
|
8
9
|
from tgit.commit import define_commit_parser
|
|
9
10
|
from tgit.utils import console
|
|
@@ -24,6 +25,7 @@ def main():
|
|
|
24
25
|
define_commit_parser(subparsers)
|
|
25
26
|
define_version_parser(subparsers)
|
|
26
27
|
define_changelog_parser(subparsers)
|
|
28
|
+
define_add_parser(subparsers)
|
|
27
29
|
|
|
28
30
|
args = parser.parse_args()
|
|
29
31
|
handle(parser, args)
|
|
@@ -70,7 +70,11 @@ def get_ai_command() -> str | None:
|
|
|
70
70
|
messages=[
|
|
71
71
|
{
|
|
72
72
|
"role": "system",
|
|
73
|
-
"content":
|
|
73
|
+
"content": "You are a git bot. You should read the diff and suggest a commit message. "
|
|
74
|
+
+ "Only if the changes are not compatible with previous versions (change the API, break the build, etc.), you should suggest a breaking change. "
|
|
75
|
+
+ f"The type should be one of {types}. The message should in all lowercase. And it shoud be short, in just few words. "
|
|
76
|
+
+ "The scope should be short, it is better to be a single word. "
|
|
77
|
+
+ "The message should cover all the changes in the diff. It should be in present tense. If the change has many parts, you can && to separate them, and you should also shorten the message. ",
|
|
74
78
|
},
|
|
75
79
|
{"role": "user", "content": diff},
|
|
76
80
|
],
|
|
@@ -42,6 +42,15 @@ def get_commit_command(commit_type: str, commit_scope: Optional[str], commit_msg
|
|
|
42
42
|
return f'git commit -m "{msg}"'
|
|
43
43
|
|
|
44
44
|
|
|
45
|
+
def simple_run_command(command: str):
|
|
46
|
+
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
47
|
+
stdout, stderr = process.communicate()
|
|
48
|
+
if stderr != b"" and process.returncode != 0:
|
|
49
|
+
sys.stderr.write(stderr.decode())
|
|
50
|
+
if stdout != b"":
|
|
51
|
+
sys.stdout.write(stdout.decode())
|
|
52
|
+
|
|
53
|
+
|
|
45
54
|
def run_command(command: str):
|
|
46
55
|
if settings.get("show_command", True):
|
|
47
56
|
panel = Panel.fit(
|
|
@@ -63,6 +63,60 @@ class VersionArgs:
|
|
|
63
63
|
prepatch: str
|
|
64
64
|
preminor: str
|
|
65
65
|
premajor: str
|
|
66
|
+
recursive: bool
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class VersionChoice:
|
|
70
|
+
def __init__(self, previous_version: Version, bump: str):
|
|
71
|
+
self.previous_version = previous_version
|
|
72
|
+
self.bump = bump
|
|
73
|
+
if bump == "major":
|
|
74
|
+
self.next_version = Version(
|
|
75
|
+
major=previous_version.major + 1,
|
|
76
|
+
minor=0,
|
|
77
|
+
patch=0,
|
|
78
|
+
)
|
|
79
|
+
elif bump == "minor":
|
|
80
|
+
self.next_version = Version(
|
|
81
|
+
major=previous_version.major,
|
|
82
|
+
minor=previous_version.minor + 1,
|
|
83
|
+
patch=0,
|
|
84
|
+
)
|
|
85
|
+
elif bump == "patch":
|
|
86
|
+
self.next_version = Version(
|
|
87
|
+
major=previous_version.major,
|
|
88
|
+
minor=previous_version.minor,
|
|
89
|
+
patch=previous_version.patch + 1,
|
|
90
|
+
)
|
|
91
|
+
elif bump == "premajor":
|
|
92
|
+
self.next_version = Version(
|
|
93
|
+
major=previous_version.major + 1,
|
|
94
|
+
minor=0,
|
|
95
|
+
patch=0,
|
|
96
|
+
release="{RELEASE}",
|
|
97
|
+
)
|
|
98
|
+
elif bump == "preminor":
|
|
99
|
+
self.next_version = Version(
|
|
100
|
+
major=previous_version.major,
|
|
101
|
+
minor=previous_version.minor + 1,
|
|
102
|
+
patch=0,
|
|
103
|
+
release="{RELEASE}",
|
|
104
|
+
)
|
|
105
|
+
elif bump == "prepatch":
|
|
106
|
+
self.next_version = Version(
|
|
107
|
+
major=previous_version.major,
|
|
108
|
+
minor=previous_version.minor,
|
|
109
|
+
patch=previous_version.patch + 1,
|
|
110
|
+
release="{RELEASE}",
|
|
111
|
+
)
|
|
112
|
+
elif bump == "previous":
|
|
113
|
+
self.next_version = previous_version
|
|
114
|
+
|
|
115
|
+
def __str__(self):
|
|
116
|
+
if "next_version" in self.__dict__:
|
|
117
|
+
return f"{self.bump} ({self.next_version})"
|
|
118
|
+
else:
|
|
119
|
+
return self.bump
|
|
66
120
|
|
|
67
121
|
|
|
68
122
|
def get_prev_version():
|
|
@@ -140,9 +194,10 @@ def handle_version(args: VersionArgs):
|
|
|
140
194
|
# return
|
|
141
195
|
|
|
142
196
|
prev_version = get_current_version(verbose)
|
|
197
|
+
reclusive = args.recursive
|
|
143
198
|
|
|
144
199
|
if next_version := get_next_version(args, prev_version, verbose):
|
|
145
|
-
update_version_files(next_version, verbose)
|
|
200
|
+
update_version_files(next_version, reclusive, verbose)
|
|
146
201
|
execute_git_commands(args, next_version, verbose)
|
|
147
202
|
|
|
148
203
|
|
|
@@ -218,7 +273,7 @@ def get_next_version(args, prev_version, verbose):
|
|
|
218
273
|
return next_version
|
|
219
274
|
|
|
220
275
|
|
|
221
|
-
def bump_version(target, next_version):
|
|
276
|
+
def bump_version(target: VersionChoice, next_version: Version):
|
|
222
277
|
if target.bump in ["patch", "prepatch"]:
|
|
223
278
|
next_version.patch += 1
|
|
224
279
|
elif target.bump in ["minor", "preminor"]:
|
|
@@ -264,13 +319,38 @@ def get_custom_version() -> Optional[Version]:
|
|
|
264
319
|
return Version.from_str(version)
|
|
265
320
|
|
|
266
321
|
|
|
267
|
-
def update_version_files(next_version: Version, verbose: int):
|
|
322
|
+
def update_version_files(next_version: Version, reclusive: bool, verbose: int):
|
|
268
323
|
next_version_str = str(next_version)
|
|
269
324
|
|
|
325
|
+
current_path = os.getcwd()
|
|
270
326
|
if verbose > 0:
|
|
271
|
-
current_path = os.getcwd()
|
|
272
327
|
console.print(f"Current path: [cyan bold]{current_path}")
|
|
273
328
|
|
|
329
|
+
if reclusive:
|
|
330
|
+
# 获取当前目录及其子目录下,所有名称在上述列表中的文件
|
|
331
|
+
# 使用os.walk()函数,可以遍历指定目录下的所有子目录和文件
|
|
332
|
+
filenames = ["package.json", "pyproject.toml", "setup.py", "Cargo.toml", "VERSION", "VERSION.txt"]
|
|
333
|
+
for root, _, files in os.walk(current_path):
|
|
334
|
+
for file in files:
|
|
335
|
+
if file in filenames:
|
|
336
|
+
file_path = os.path.join(root, file)
|
|
337
|
+
if file == "package.json":
|
|
338
|
+
update_file(file_path, r'"version":\s*".*?"', f'"version": "{next_version_str}"', verbose, show_diff=False)
|
|
339
|
+
elif file == "pyproject.toml":
|
|
340
|
+
update_file(file_path, r'version\s*=\s*".*?"', f'version = "{next_version_str}"', verbose, show_diff=False)
|
|
341
|
+
elif file == "setup.py":
|
|
342
|
+
update_file(file_path, r"version=['\"].*?['\"]", f"version='{next_version_str}'", verbose, show_diff=False)
|
|
343
|
+
elif file == "Cargo.toml":
|
|
344
|
+
update_file(file_path, r'version\s*=\s*".*?"', f'version = "{next_version_str}"', verbose, show_diff=False)
|
|
345
|
+
elif file == "VERSION":
|
|
346
|
+
update_file(file_path, None, next_version_str, verbose, show_diff=False)
|
|
347
|
+
elif file == "VERSION.txt":
|
|
348
|
+
update_file(file_path, None, next_version_str, verbose, show_diff=False)
|
|
349
|
+
else:
|
|
350
|
+
update_file_in_root(next_version_str, verbose)
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
def update_file_in_root(next_version_str, verbose):
|
|
274
354
|
update_file("package.json", r'"version":\s*".*?"', f'"version": "{next_version_str}"', verbose)
|
|
275
355
|
update_file("pyproject.toml", r'version\s*=\s*".*?"', f'version = "{next_version_str}"', verbose)
|
|
276
356
|
update_file("setup.py", r"version=['\"].*?['\"]", f"version='{next_version_str}'", verbose)
|
|
@@ -361,59 +441,6 @@ def execute_git_commands(args: VersionArgs, next_version: Version, verbose: int)
|
|
|
361
441
|
run_command(commands_str)
|
|
362
442
|
|
|
363
443
|
|
|
364
|
-
class VersionChoice:
|
|
365
|
-
def __init__(self, previous_version: Version, bump: str):
|
|
366
|
-
self.previous_version = previous_version
|
|
367
|
-
self.bump = bump
|
|
368
|
-
if bump == "major":
|
|
369
|
-
self.next_version = Version(
|
|
370
|
-
major=previous_version.major + 1,
|
|
371
|
-
minor=0,
|
|
372
|
-
patch=0,
|
|
373
|
-
)
|
|
374
|
-
elif bump == "minor":
|
|
375
|
-
self.next_version = Version(
|
|
376
|
-
major=previous_version.major,
|
|
377
|
-
minor=previous_version.minor + 1,
|
|
378
|
-
patch=0,
|
|
379
|
-
)
|
|
380
|
-
elif bump == "patch":
|
|
381
|
-
self.next_version = Version(
|
|
382
|
-
major=previous_version.major,
|
|
383
|
-
minor=previous_version.minor,
|
|
384
|
-
patch=previous_version.patch + 1,
|
|
385
|
-
)
|
|
386
|
-
elif bump == "premajor":
|
|
387
|
-
self.next_version = Version(
|
|
388
|
-
major=previous_version.major + 1,
|
|
389
|
-
minor=0,
|
|
390
|
-
patch=0,
|
|
391
|
-
release="{RELEASE}",
|
|
392
|
-
)
|
|
393
|
-
elif bump == "preminor":
|
|
394
|
-
self.next_version = Version(
|
|
395
|
-
major=previous_version.major,
|
|
396
|
-
minor=previous_version.minor + 1,
|
|
397
|
-
patch=0,
|
|
398
|
-
release="{RELEASE}",
|
|
399
|
-
)
|
|
400
|
-
elif bump == "prepatch":
|
|
401
|
-
self.next_version = Version(
|
|
402
|
-
major=previous_version.major,
|
|
403
|
-
minor=previous_version.minor,
|
|
404
|
-
patch=previous_version.patch + 1,
|
|
405
|
-
release="{RELEASE}",
|
|
406
|
-
)
|
|
407
|
-
elif bump == "previous":
|
|
408
|
-
self.next_version = previous_version
|
|
409
|
-
|
|
410
|
-
def __str__(self):
|
|
411
|
-
if "next_version" in self.__dict__:
|
|
412
|
-
return f"{self.bump} ({self.next_version})"
|
|
413
|
-
else:
|
|
414
|
-
return self.bump
|
|
415
|
-
|
|
416
|
-
|
|
417
444
|
def define_version_parser(subparsers):
|
|
418
445
|
parser_version = subparsers.add_parser("version", help="bump version of the project")
|
|
419
446
|
parser_version.add_argument("-v", "--verbose", action="count", default=0, help="increase output verbosity")
|
|
@@ -421,8 +448,8 @@ def define_version_parser(subparsers):
|
|
|
421
448
|
parser_version.add_argument("--no-tag", action="store_true", help="do not create a tag")
|
|
422
449
|
parser_version.add_argument("--no-push", action="store_true", help="do not push the changes")
|
|
423
450
|
|
|
424
|
-
#
|
|
425
|
-
|
|
451
|
+
# add option to bump all packages in the monorepo
|
|
452
|
+
parser_version.add_argument("-r", "--recursive", action="store_true", help="bump all packages in the monorepo")
|
|
426
453
|
|
|
427
454
|
# create a mutually exclusive group
|
|
428
455
|
version_group = parser_version.add_mutually_exclusive_group()
|
|
@@ -435,4 +462,5 @@ def define_version_parser(subparsers):
|
|
|
435
462
|
version_group.add_argument("-pm", "--preminor", help="preminor version", type=str)
|
|
436
463
|
version_group.add_argument("-pM", "--premajor", help="premajor version", type=str)
|
|
437
464
|
version_group.add_argument("version", help="version to bump to", type=str, nargs="?")
|
|
465
|
+
|
|
438
466
|
parser_version.set_defaults(func=handle_version)
|
tgit-0.8.0/.python-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.12.5
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|