tgit 0.5.0__tar.gz → 0.6.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.5.0 → tgit-0.6.0}/PKG-INFO +1 -1
- {tgit-0.5.0 → tgit-0.6.0}/pyproject.toml +1 -1
- {tgit-0.5.0 → tgit-0.6.0}/tgit/changelog.py +21 -15
- {tgit-0.5.0 → tgit-0.6.0}/tgit/commit.py +10 -2
- {tgit-0.5.0 → tgit-0.6.0}/tgit/utils.py +1 -1
- {tgit-0.5.0 → tgit-0.6.0}/tgit/version.py +27 -5
- {tgit-0.5.0 → tgit-0.6.0}/.gitignore +0 -0
- {tgit-0.5.0 → tgit-0.6.0}/.python-version +0 -0
- {tgit-0.5.0 → tgit-0.6.0}/.tgit.yml +0 -0
- {tgit-0.5.0 → tgit-0.6.0}/.vscode/settings.json +0 -0
- {tgit-0.5.0 → tgit-0.6.0}/README.md +0 -0
- {tgit-0.5.0 → tgit-0.6.0}/requirements-dev.lock +0 -0
- {tgit-0.5.0 → tgit-0.6.0}/requirements.lock +0 -0
- {tgit-0.5.0 → tgit-0.6.0}/scripts/publish.sh +0 -0
- {tgit-0.5.0 → tgit-0.6.0}/tgit/__init__.py +0 -0
- {tgit-0.5.0 → tgit-0.6.0}/tgit/cli.py +0 -0
- {tgit-0.5.0 → tgit-0.6.0}/tgit/settings.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: tgit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "tgit"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.6.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 = [
|
|
@@ -217,21 +217,10 @@ def generate_changelog(commits_by_type: dict[str, list[TGITCommit]], from_ref: s
|
|
|
217
217
|
|
|
218
218
|
def handle_changelog(args: ChangelogArgs):
|
|
219
219
|
repo = git.Repo(args.path)
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
tags = repo.tags
|
|
225
|
-
latest_commit_tags = [tag for tag in tags if tag.commit == latest_commit]
|
|
226
|
-
if latest_commit_tags:
|
|
227
|
-
to_ref = from_ref
|
|
228
|
-
from_ref = get_tag_by_idx(repo, -2)
|
|
229
|
-
if from_ref is None:
|
|
230
|
-
from_ref = get_first_commit_hash(repo)
|
|
231
|
-
else:
|
|
232
|
-
warnings.warn("HEAD is not a tag, changelog will be generated from the last tag to HEAD.")
|
|
233
|
-
from_hash = ref_to_hash(repo, from_ref)
|
|
234
|
-
to_hash = ref_to_hash(repo, to_ref)
|
|
220
|
+
from_raw = args.from_raw
|
|
221
|
+
to_raw = args.to_raw
|
|
222
|
+
print(from_raw, to_raw)
|
|
223
|
+
from_ref, to_ref, from_hash, to_hash = get_git_commits_range(repo, from_raw, to_raw)
|
|
235
224
|
|
|
236
225
|
try:
|
|
237
226
|
origin_url = repo.remote().url
|
|
@@ -245,3 +234,20 @@ def handle_changelog(args: ChangelogArgs):
|
|
|
245
234
|
changelog = generate_changelog(commits_by_type, from_ref, to_ref, remote_uri)
|
|
246
235
|
print()
|
|
247
236
|
print(changelog)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def get_git_commits_range(repo: git.Repo, from_raw: str, to_raw: str):
|
|
240
|
+
from_ref = resolve_from_ref(repo, from_raw)
|
|
241
|
+
to_ref = "HEAD" if to_raw is None else to_raw
|
|
242
|
+
if to_ref == "HEAD":
|
|
243
|
+
latest_commit = repo.head.commit
|
|
244
|
+
tags = repo.tags
|
|
245
|
+
latest_commit_tags = [tag for tag in tags if tag.commit == latest_commit]
|
|
246
|
+
if latest_commit_tags:
|
|
247
|
+
to_ref = from_ref
|
|
248
|
+
from_ref = get_tag_by_idx(repo, -2)
|
|
249
|
+
if from_ref is None:
|
|
250
|
+
from_ref = get_first_commit_hash(repo)
|
|
251
|
+
from_hash = ref_to_hash(repo, from_ref)
|
|
252
|
+
to_hash = ref_to_hash(repo, to_ref)
|
|
253
|
+
return from_ref, to_ref, from_hash, to_hash
|
|
@@ -7,6 +7,7 @@ from typing import Optional
|
|
|
7
7
|
import git
|
|
8
8
|
from openai import OpenAI
|
|
9
9
|
from pydantic import BaseModel
|
|
10
|
+
from rich import print
|
|
10
11
|
|
|
11
12
|
from tgit.settings import settings
|
|
12
13
|
from tgit.utils import get_commit_command, run_command, type_emojis
|
|
@@ -23,7 +24,11 @@ def define_commit_parser(subparsers: argparse._SubParsersAction):
|
|
|
23
24
|
commit_type.append(data.get("type"))
|
|
24
25
|
|
|
25
26
|
parser_commit = subparsers.add_parser("commit", help="commit changes following the conventional commit format")
|
|
26
|
-
parser_commit.add_argument(
|
|
27
|
+
parser_commit.add_argument(
|
|
28
|
+
"message",
|
|
29
|
+
help="commit message, the first word should be the type, if the message is more than two parts, the second part should be the scope",
|
|
30
|
+
nargs="*",
|
|
31
|
+
)
|
|
27
32
|
parser_commit.add_argument("-v", "--verbose", action="count", default=0, help="increase output verbosity")
|
|
28
33
|
parser_commit.add_argument("-e", "--emoji", action="store_true", help="use emojis")
|
|
29
34
|
parser_commit.add_argument("-b", "--breaking", action="store_true", help="breaking change")
|
|
@@ -66,7 +71,7 @@ def get_ai_command():
|
|
|
66
71
|
response_format=CommitData,
|
|
67
72
|
)
|
|
68
73
|
resp = chat_completion.choices[0].message.parsed
|
|
69
|
-
return get_commit_command(resp.type, resp.scope, resp.msg,
|
|
74
|
+
return get_commit_command(resp.type, resp.scope, resp.msg, settings.get("commit", {}).get("emoji", False), resp.is_breaking)
|
|
70
75
|
|
|
71
76
|
|
|
72
77
|
def handle_commit(args: CommitArgs):
|
|
@@ -79,6 +84,9 @@ def handle_commit(args: CommitArgs):
|
|
|
79
84
|
command = get_ai_command()
|
|
80
85
|
else:
|
|
81
86
|
messages = args.message
|
|
87
|
+
if len(messages) == 0:
|
|
88
|
+
print("Please provide a commit message, or use --ai to generate by AI")
|
|
89
|
+
return
|
|
82
90
|
commit_type = messages[0]
|
|
83
91
|
if len(messages) > 2:
|
|
84
92
|
commit_scope = messages[1]
|
|
@@ -36,7 +36,7 @@ def get_commit_command(commit_type: str, commit_scope: Optional[str], commit_msg
|
|
|
36
36
|
if commit_scope is None:
|
|
37
37
|
msg = f"{commit_type}{breaking_str}: {commit_msg}"
|
|
38
38
|
else:
|
|
39
|
-
msg = f"{commit_type}
|
|
39
|
+
msg = f"{commit_type}({commit_scope}){breaking_str}: {commit_msg}"
|
|
40
40
|
if use_emoji:
|
|
41
41
|
msg = f"{type_emojis.get(commit_type, ':wrench:' )} {msg}"
|
|
42
42
|
return f'git commit -m "{msg}"'
|
|
@@ -7,9 +7,11 @@ from dataclasses import dataclass
|
|
|
7
7
|
from difflib import Differ
|
|
8
8
|
from typing import Optional
|
|
9
9
|
|
|
10
|
+
import git
|
|
10
11
|
import inquirer
|
|
11
12
|
from rich.panel import Panel
|
|
12
13
|
|
|
14
|
+
from tgit.changelog import get_commits, get_git_commits_range, group_commits_by_type
|
|
13
15
|
from tgit.settings import settings
|
|
14
16
|
from tgit.utils import console, get_commit_command, run_command
|
|
15
17
|
|
|
@@ -123,13 +125,22 @@ def get_prev_version():
|
|
|
123
125
|
return Version(major=0, minor=0, patch=0)
|
|
124
126
|
|
|
125
127
|
|
|
128
|
+
def get_default_bump_by_commits_dict(commits_by_type: dict[str, list[git.Commit]]) -> str:
|
|
129
|
+
if commits_by_type.get("breaking"):
|
|
130
|
+
return "major"
|
|
131
|
+
elif commits_by_type.get("feat"):
|
|
132
|
+
return "minor"
|
|
133
|
+
return "patch"
|
|
134
|
+
|
|
135
|
+
|
|
126
136
|
def handle_version(args: VersionArgs):
|
|
127
137
|
verbose = args.verbose
|
|
128
138
|
|
|
129
|
-
#
|
|
130
|
-
#
|
|
139
|
+
# if not check_uncommitted_changes(verbose):
|
|
140
|
+
# return
|
|
131
141
|
|
|
132
142
|
prev_version = get_current_version(verbose)
|
|
143
|
+
|
|
133
144
|
if next_version := get_next_version(args, prev_version, verbose):
|
|
134
145
|
update_version_files(next_version, verbose)
|
|
135
146
|
execute_git_commands(args, next_version, verbose)
|
|
@@ -158,16 +169,27 @@ def get_current_version(verbose: int) -> Optional[Version]:
|
|
|
158
169
|
|
|
159
170
|
|
|
160
171
|
def get_next_version(args, prev_version, verbose):
|
|
172
|
+
|
|
173
|
+
repo = git.Repo(os.getcwd())
|
|
174
|
+
_, _, from_hash, to_hash = get_git_commits_range(repo, None, None)
|
|
175
|
+
tgit_commits = get_commits(repo, from_hash, to_hash)
|
|
176
|
+
commits_by_type = group_commits_by_type(tgit_commits)
|
|
177
|
+
default_bump = get_default_bump_by_commits_dict(commits_by_type)
|
|
178
|
+
|
|
179
|
+
choices = [VersionChoice(prev_version, bump) for bump in ["patch", "minor", "major", "prepatch", "preminor", "premajor", "previous", "custom"]]
|
|
180
|
+
default_choice = next((choice for choice in choices if choice.bump == default_bump), None)
|
|
161
181
|
next_version = deepcopy(prev_version)
|
|
182
|
+
|
|
183
|
+
console.print(f"Auto bump based on commits: [cyan bold]{default_bump}")
|
|
184
|
+
|
|
162
185
|
if not any([args.version, args.patch, args.minor, args.major, args.prepatch, args.preminor, args.premajor]):
|
|
163
186
|
ans = inquirer.prompt(
|
|
164
187
|
[
|
|
165
188
|
inquirer.List(
|
|
166
189
|
"target",
|
|
167
190
|
message="Select the version to bump to",
|
|
168
|
-
choices=
|
|
169
|
-
|
|
170
|
-
],
|
|
191
|
+
choices=choices,
|
|
192
|
+
default=default_choice,
|
|
171
193
|
carousel=True,
|
|
172
194
|
),
|
|
173
195
|
]
|
|
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
|
|
File without changes
|
|
File without changes
|