@@ -1188,6 +1188,15 @@ def _apply_update(self) -> None: # noqa: C901
11881188 ).strip ()
11891189 )
11901190 subproject_subdir = self .subproject .local_abspath .relative_to (subproject_top )
1191+ subproject_git_config_path = Path (
1192+ git (
1193+ "-C" ,
1194+ self .subproject .local_abspath ,
1195+ "rev-parse" ,
1196+ "--absolute-git-dir" ,
1197+ ).strip (),
1198+ "config" ,
1199+ )
11911200
11921201 with (
11931202 TemporaryDirectory (
@@ -1211,6 +1220,13 @@ def _apply_update(self) -> None: # noqa: C901
12111220 # https://github.com/orgs/copier-org/discussions/2345
12121221 exclude = [* self .template .exclude , * self .exclude ],
12131222 ) as old_worker :
1223+ # Initialize a Git repository in the temporary destination and configure
1224+ # it to include the Git configuration of the real destination, so
1225+ # tasks/migrations that rely on Git configuration (e.g., GitHub CLI) can
1226+ # work properly when running in the temporary destination.
1227+ with local .cwd (old_copy ):
1228+ git ("init" )
1229+ git ("config" , "include.path" , subproject_git_config_path )
12141230 old_worker .run_copy ()
12151231 # Run pre-migration tasks
12161232 with Phase .use (Phase .MIGRATE ):
@@ -1222,7 +1238,8 @@ def _apply_update(self) -> None: # noqa: C901
12221238 with local .cwd (subproject_top ):
12231239 subproject_head = git ("write-tree" ).strip ()
12241240 with local .cwd (old_copy ):
1225- self ._git_initialize_repo ()
1241+ git ("add" , "." )
1242+ self ._git_commit ()
12261243 # Configure borrowing Git objects from the real destination.
12271244 set_git_alternates (subproject_top )
12281245 # Save a list of files that were intentionally removed in the generated
@@ -1282,9 +1299,17 @@ def _apply_update(self) -> None: # noqa: C901
12821299 exclude = exclude_plus_removed ,
12831300 vcs_ref = self .resolved_vcs_ref ,
12841301 ) as new_worker :
1302+ # Initialize a Git repository in the temporary destination and configure
1303+ # it to include the Git configuration of the real destination, so
1304+ # tasks/migrations that rely on Git configuration (e.g., GitHub CLI) can
1305+ # work properly when running in the temporary destination.
1306+ with local .cwd (new_copy ):
1307+ git ("init" )
1308+ git ("config" , "include.path" , subproject_git_config_path )
12851309 new_worker .run_copy ()
12861310 with local .cwd (new_copy ):
1287- self ._git_initialize_repo ()
1311+ git ("add" , "." )
1312+ self ._git_commit ()
12881313 new_copy_head = git ("rev-parse" , "HEAD" ).strip ()
12891314 # Extract diff between temporary destination and real destination
12901315 # with some special handling of newly added files in both the project
@@ -1474,13 +1499,6 @@ def _apply_update(self) -> None: # noqa: C901
14741499 self .template .migration_tasks ("after" , self .subproject .template ) # type: ignore[arg-type]
14751500 )
14761501
1477- def _git_initialize_repo (self ) -> None :
1478- """Initialize a git repository in the current directory."""
1479- git = get_git ()
1480- git ("init" , retcode = None )
1481- git ("add" , "." )
1482- self ._git_commit ()
1483-
14841502 def _git_commit (self , message : str = "dumb commit" ) -> None :
14851503 git = get_git ()
14861504 # 1st commit could fail if any pre-commit hook reformats code
0 commit comments