MCPcopy Create free account
hub / github.com/BillHuang2001/evogit / init_git_repo

Function init_git_repo

python-impl/evogit/utils/git.py:91–130  ·  view source on GitHub ↗
(config: EvoGitConfig)

Source from the content-addressed store, hash-verified

89
90
91def init_git_repo(config: EvoGitConfig) -> None:
92 git_dir = config.git_dir
93
94 subprocess.run(
95 ["git", "init", "--object-format", config.git_hash], cwd=git_dir, check=True
96 )
97 subprocess.run(
98 ["git", "config", "user.name", config.git_user_name], cwd=git_dir, check=True
99 )
100 subprocess.run(
101 ["git", "config", "user.email", config.git_user_email], cwd=git_dir, check=True
102 )
103 if os.path.isdir(config.seed_file):
104 shutil.copytree(config.seed_file, git_dir)
105 else:
106 shutil.copy(config.seed_file, os.path.join(git_dir, config.filename))
107
108 subprocess.run(["git", "add", "."], cwd=git_dir, check=True)
109 subprocess.run(["git", "commit", "-q", "-m", "init"], cwd=git_dir, check=True)
110 # disable auto gc, since we will run it manually at the end of each evaluation
111 subprocess.run(["git", "config", "gc.auto", "0"], cwd=git_dir, check=True)
112 config_merge_driver(config)
113
114 if config.remote_repo is not None:
115 subprocess.run(
116 ["git", "remote", "add", "origin", config.remote_repo],
117 cwd=git_dir,
118 check=True,
119 )
120 subprocess.run(
121 ["git", "push", "-f", "origin", "master"], cwd=git_dir, check=True
122 )
123 subprocess.run(
124 ["git", "push", "-d", "origin", "refs/notes/commits"],
125 cwd=git_dir,
126 check=True,
127 )
128
129 delete_remote_branches(config)
130 delete_remote_notes(config)
131
132
133def clone_git_repo(config: EvoGitConfig) -> None:

Callers

nothing calls this directly

Calls 3

config_merge_driverFunction · 0.85
delete_remote_branchesFunction · 0.85
delete_remote_notesFunction · 0.85

Tested by

no test coverage detected