Skip to content

Commit 82199b1

Browse files
authored
Merge pull request #1753 from hesreallyhim/hesreallyhim/git-small-fixes-with-typing-and-strings
[FIX] `mcp_server_git`: replace deprecated pydantic functions and small fixes to typing issues
2 parents 6566e1c + b461806 commit 82199b1

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

git/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ dev-dependencies = ["pyright>=1.1.389", "ruff>=0.7.3", "pytest>=8.0.0"]
3636
testpaths = ["tests"]
3737
python_files = "test_*.py"
3838
python_classes = "Test*"
39-
python_functions = "test_*"
39+
python_functions = "test_*"

git/src/mcp_server_git/py.typed

Whitespace-only changes.

git/src/mcp_server_git/server.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,16 @@ def git_log(repo: git.Repo, max_count: int = 10) -> list[str]:
102102
log = []
103103
for commit in commits:
104104
log.append(
105-
f"Commit: {commit.hexsha}\n"
106-
f"Author: {commit.author}\n"
105+
f"Commit: {commit.hexsha!r}\n"
106+
f"Author: {commit.author!r}\n"
107107
f"Date: {commit.authored_datetime}\n"
108-
f"Message: {commit.message}\n"
108+
f"Message: {commit.message!r}\n"
109109
)
110110
return log
111111

112112
def git_create_branch(repo: git.Repo, branch_name: str, base_branch: str | None = None) -> str:
113113
if base_branch:
114-
base = repo.refs[base_branch]
114+
base = repo.references[base_branch]
115115
else:
116116
base = repo.active_branch
117117

@@ -132,10 +132,10 @@ def git_init(repo_path: str) -> str:
132132
def git_show(repo: git.Repo, revision: str) -> str:
133133
commit = repo.commit(revision)
134134
output = [
135-
f"Commit: {commit.hexsha}\n"
136-
f"Author: {commit.author}\n"
137-
f"Date: {commit.authored_datetime}\n"
138-
f"Message: {commit.message}\n"
135+
f"Commit: {commit.hexsha!r}\n"
136+
f"Author: {commit.author!r}\n"
137+
f"Date: {commit.authored_datetime!r}\n"
138+
f"Message: {commit.message!r}\n"
139139
]
140140
if commit.parents:
141141
parent = commit.parents[0]
@@ -166,62 +166,62 @@ async def list_tools() -> list[Tool]:
166166
Tool(
167167
name=GitTools.STATUS,
168168
description="Shows the working tree status",
169-
inputSchema=GitStatus.schema(),
169+
inputSchema=GitStatus.model_json_schema(),
170170
),
171171
Tool(
172172
name=GitTools.DIFF_UNSTAGED,
173173
description="Shows changes in the working directory that are not yet staged",
174-
inputSchema=GitDiffUnstaged.schema(),
174+
inputSchema=GitDiffUnstaged.model_json_schema(),
175175
),
176176
Tool(
177177
name=GitTools.DIFF_STAGED,
178178
description="Shows changes that are staged for commit",
179-
inputSchema=GitDiffStaged.schema(),
179+
inputSchema=GitDiffStaged.model_json_schema(),
180180
),
181181
Tool(
182182
name=GitTools.DIFF,
183183
description="Shows differences between branches or commits",
184-
inputSchema=GitDiff.schema(),
184+
inputSchema=GitDiff.model_json_schema(),
185185
),
186186
Tool(
187187
name=GitTools.COMMIT,
188188
description="Records changes to the repository",
189-
inputSchema=GitCommit.schema(),
189+
inputSchema=GitCommit.model_json_schema(),
190190
),
191191
Tool(
192192
name=GitTools.ADD,
193193
description="Adds file contents to the staging area",
194-
inputSchema=GitAdd.schema(),
194+
inputSchema=GitAdd.model_json_schema(),
195195
),
196196
Tool(
197197
name=GitTools.RESET,
198198
description="Unstages all staged changes",
199-
inputSchema=GitReset.schema(),
199+
inputSchema=GitReset.model_json_schema(),
200200
),
201201
Tool(
202202
name=GitTools.LOG,
203203
description="Shows the commit logs",
204-
inputSchema=GitLog.schema(),
204+
inputSchema=GitLog.model_json_schema(),
205205
),
206206
Tool(
207207
name=GitTools.CREATE_BRANCH,
208208
description="Creates a new branch from an optional base branch",
209-
inputSchema=GitCreateBranch.schema(),
209+
inputSchema=GitCreateBranch.model_json_schema(),
210210
),
211211
Tool(
212212
name=GitTools.CHECKOUT,
213213
description="Switches branches",
214-
inputSchema=GitCheckout.schema(),
214+
inputSchema=GitCheckout.model_json_schema(),
215215
),
216216
Tool(
217217
name=GitTools.SHOW,
218218
description="Shows the contents of a commit",
219-
inputSchema=GitShow.schema(),
219+
inputSchema=GitShow.model_json_schema(),
220220
),
221221
Tool(
222222
name=GitTools.INIT,
223223
description="Initialize a new Git repository",
224-
inputSchema=GitInit.schema(),
224+
inputSchema=GitInit.model_json_schema(),
225225
)
226226
]
227227

0 commit comments

Comments
 (0)