Skip to content

Commit de1338c

Browse files
dberenbaumdberenbaum
authored andcommitted
write git config to exp tmp repos
1 parent 9957410 commit de1338c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

dvc/repo/experiments/executor/local.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ def init_git(
130130

131131
self.scm.stash.apply(merge_rev)
132132
self._update_config(repo.config.read("local"))
133+
local_git_config = os.path.join(repo.scm.root_dir, ".git", "config")
134+
self._update_git_config(ConfigObj(local_git_config, list_values=False))
133135

134136
def _update_config(self, update):
135137
local_config = os.path.join(self.root_dir, self.dvc_dir, "config.local")
@@ -143,6 +145,18 @@ def _update_config(self, update):
143145
with open(local_config, "wb") as fobj:
144146
conf_obj.write(fobj)
145147

148+
def _update_git_config(self, update):
149+
local_config = os.path.join(self.scm.root_dir, ".git", "config")
150+
logger.debug("Writing experiments local Git config '%s'", local_config)
151+
if os.path.exists(local_config):
152+
conf_obj = ConfigObj(local_config, list_values=False)
153+
conf_obj.merge(update)
154+
else:
155+
conf_obj = ConfigObj(update, list_values=False)
156+
if conf_obj:
157+
with open(local_config, "wb") as fobj:
158+
conf_obj.write(fobj)
159+
146160
def init_cache(
147161
self,
148162
repo: "Repo",
@@ -155,7 +169,7 @@ def init_cache(
155169
def cleanup(self, infofile: Optional[str] = None):
156170
super().cleanup(infofile)
157171
logger.debug("Removing tmpdir '%s'", self.root_dir)
158-
remove(self.root_dir)
172+
# remove(self.root_dir)
159173

160174
@classmethod
161175
def from_stash_entry(

0 commit comments

Comments
 (0)