Skip to content

Commit ab13daa

Browse files
committed
fix: configure Git identity for tests
Sorry, you should still init codemcp. This is for the CI for codemcp project. You should fix the tests so that author/email are set. ```git-revs 51af7f7 (Base revision) HEAD Add Git user identity configuration for CI environments ``` codemcp-id: 276-fix-configure-git-identity-for-tests ghstack-source-id: 41bf57f Pull-Request-resolved: #269
1 parent b8ee25a commit ab13daa

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

codemcp/main.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,45 @@ def init_codemcp_project(path: str, python: bool = False) -> str:
658658
else:
659659
print(f"Git repository already exists in {project_path}")
660660

661+
# Ensure Git user identity is configured for the repository
662+
# This is especially important for CI environments
663+
try:
664+
# Check if user.name is set
665+
name_result = subprocess.run(
666+
["git", "config", "user.name"],
667+
cwd=project_path,
668+
capture_output=True,
669+
text=True,
670+
check=False,
671+
)
672+
if name_result.returncode != 0:
673+
# Set a default user name if not configured
674+
subprocess.run(
675+
["git", "config", "user.name", "CodeMCP User"],
676+
cwd=project_path,
677+
check=True,
678+
)
679+
print("Set default Git user name")
680+
681+
# Check if user.email is set
682+
email_result = subprocess.run(
683+
["git", "config", "user.email"],
684+
cwd=project_path,
685+
capture_output=True,
686+
text=True,
687+
check=False,
688+
)
689+
if email_result.returncode != 0:
690+
# Set a default user email if not configured
691+
subprocess.run(
692+
["git", "config", "user.email", "[email protected]"],
693+
cwd=project_path,
694+
check=True,
695+
)
696+
print("Set default Git user email")
697+
except Exception as e:
698+
print(f"Warning: Could not configure Git user identity: {e}")
699+
661700
# Select the appropriate template directory
662701
template_name = "python" if python else "blank"
663702
templates_dir = Path(__file__).parent / "templates" / template_name

0 commit comments

Comments
 (0)