Skip to content

Commit 68cde6c

Browse files
committed
fix: detach stdin on remaining git subprocess calls
Apply the same stdin=DEVNULL treatment to the git clone/config/checkout calls in cloning.py and github_processor.py so no git child process inherits the parent's stdin (the MCP JSON-RPC pipe when run as a server, or an interactive terminal where git could otherwise block on a prompt).
1 parent 01a4b97 commit 68cde6c

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎codewiki/src/be/dependency_analyzer/analysis/cloning.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def clone_repository(github_url: str) -> str:
8888
"true",
8989
],
9090
capture_output=True,
91+
stdin=subprocess.DEVNULL,
9192
text=True,
9293
)
9394
except Exception:
@@ -105,6 +106,7 @@ def clone_repository(github_url: str) -> str:
105106
],
106107
check=True,
107108
capture_output=True,
109+
stdin=subprocess.DEVNULL,
108110
text=True,
109111
timeout=300,
110112
)
@@ -121,6 +123,7 @@ def clone_repository(github_url: str) -> str:
121123
"true",
122124
],
123125
capture_output=True,
126+
stdin=subprocess.DEVNULL,
124127
text=True,
125128
)
126129

@@ -144,6 +147,7 @@ def clone_repository(github_url: str) -> str:
144147
"HEAD",
145148
],
146149
capture_output=True,
150+
stdin=subprocess.DEVNULL,
147151
text=True,
148152
)
149153
except Exception:

‎codewiki/src/fe/github_processor.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def clone_repository(clone_url: str, target_dir: str, commit_id: str = None) ->
6464
result = subprocess.run(
6565
["git", "clone", clone_url, target_dir],
6666
capture_output=True,
67+
stdin=subprocess.DEVNULL,
6768
text=True,
6869
timeout=WebAppConfig.CLONE_TIMEOUT,
6970
)
@@ -77,6 +78,7 @@ def clone_repository(clone_url: str, target_dir: str, commit_id: str = None) ->
7778
["git", "checkout", commit_id],
7879
cwd=target_dir,
7980
capture_output=True,
81+
stdin=subprocess.DEVNULL,
8082
text=True,
8183
timeout=30,
8284
)
@@ -96,6 +98,7 @@ def clone_repository(clone_url: str, target_dir: str, commit_id: str = None) ->
9698
target_dir,
9799
],
98100
capture_output=True,
101+
stdin=subprocess.DEVNULL,
99102
text=True,
100103
timeout=WebAppConfig.CLONE_TIMEOUT,
101104
)

0 commit comments

Comments
 (0)