MCPcopy Index your code
hub / github.com/Codeplain-ai/codeplain / init_git_repo

Function init_git_repo

git_utils.py:63–90  ·  view source on GitHub ↗

Initializes a new git repository in the given path. If folder does not exist, it creates it. If the folder already exists, it deletes the content of the folder.

(
    path_to_repo: Union[str, os.PathLike],
    module_name: Optional[str] = None,
    render_id: Optional[str] = None,
    initial_files: Optional[dict[str, str]] = None,
)

Source from the content-addressed store, hash-verified

61
62
63def init_git_repo(
64 path_to_repo: Union[str, os.PathLike],
65 module_name: Optional[str] = None,
66 render_id: Optional[str] = None,
67 initial_files: Optional[dict[str, str]] = None,
68) -> Repo:
69 """
70 Initializes a new git repository in the given path.
71 If folder does not exist, it creates it.
72 If the folder already exists, it deletes the content of the folder.
73 """
74 if os.path.isdir(path_to_repo):
75 file_utils.delete_files_and_subfolders(path_to_repo)
76 else:
77 os.makedirs(path_to_repo)
78
79 repo = Repo.init(path_to_repo)
80 _ensure_git_config(repo)
81
82 if initial_files:
83 file_utils.store_response_files(path_to_repo, initial_files, [])
84 repo.git.add(".")
85
86 repo.git.commit(
87 "--allow-empty", "-m", _get_full_commit_message(INITIAL_COMMIT_MESSAGE, module_name, None, render_id)
88 )
89
90 return repo
91
92
93def clone_repo(

Callers 3

temp_repoFunction · 0.90
empty_repoFunction · 0.90

Calls 2

_ensure_git_configFunction · 0.85
_get_full_commit_messageFunction · 0.85

Tested by 3

temp_repoFunction · 0.72
empty_repoFunction · 0.72