Skip to content

Commit 524cb3b

Browse files
committed
Fix git credentials for merging
1 parent 8f79bce commit 524cb3b

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

src/aieng_bot_maintain/auto_merger/workflow_client.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def _manual_rebase(self, pr: PRQueueItem) -> bool:
265265
env=env,
266266
)
267267

268-
# Configure git user and credentials for commits
268+
# Configure git user for commits
269269
subprocess.run(
270270
["git", "config", "user.name", "aieng-bot-maintain[bot]"],
271271
cwd=repo_dir,
@@ -284,21 +284,8 @@ def _manual_rebase(self, pr: PRQueueItem) -> bool:
284284
capture_output=True,
285285
)
286286

287-
# Configure git to use GH_TOKEN for authentication
288-
# This sets up credential helper to use the token for HTTPS pushes
289-
subprocess.run(
290-
[
291-
"git",
292-
"config",
293-
"credential.helper",
294-
"store --file=/dev/null", # Don't persist credentials
295-
],
296-
cwd=repo_dir,
297-
check=True,
298-
capture_output=True,
299-
)
300-
301287
# Set remote URL to include token for authentication
288+
# Using x-access-token in URL provides auth without credential helper
302289
remote_url = (
303290
f"https://x-access-token:{self.gh_token}@github.com/{pr.repo}.git"
304291
)

tests/auto_merger/test_workflow_client.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,7 @@ def test_trigger_rebase_precommit_success(
217217
MagicMock(returncode=0, stdout=""),
218218
# git config user.email
219219
MagicMock(returncode=0, stdout=""),
220-
# git config credential.helper
221-
MagicMock(returncode=0, stdout=""),
222-
# git remote set-url
220+
# git remote set-url (embeds token in URL for auth)
223221
MagicMock(returncode=0, stdout=""),
224222
# git fetch origin head_ref
225223
MagicMock(returncode=0, stdout=""),
@@ -237,7 +235,7 @@ def test_trigger_rebase_precommit_success(
237235

238236
assert result is True
239237
# Should make multiple git-related calls
240-
assert mock_run.call_count == 11
238+
assert mock_run.call_count == 10
241239

242240
@patch("subprocess.run")
243241
def test_trigger_rebase_precommit_failure(
@@ -257,8 +255,6 @@ def test_trigger_rebase_precommit_failure(
257255
MagicMock(returncode=0, stdout=""),
258256
# git config user.email
259257
MagicMock(returncode=0, stdout=""),
260-
# git config credential.helper
261-
MagicMock(returncode=0, stdout=""),
262258
# git remote set-url
263259
MagicMock(returncode=0, stdout=""),
264260
# git fetch origin head_ref

0 commit comments

Comments
 (0)