@@ -50,6 +50,9 @@ export type CheckpointServiceOptions = {
5050 */
5151
5252export class CheckpointService {
53+ private static readonly USER_NAME = "Roo Code"
54+ private static readonly USER_EMAIL = "[email protected] " 55+
5356 private _currentCheckpoint ?: string
5457
5558 public get currentCheckpoint ( ) {
@@ -273,6 +276,7 @@ export class CheckpointService {
273276 log (
274277 `[CheckpointService] taskId = ${ taskId } , baseDir = ${ baseDir } , currentBranch = ${ currentBranch } , currentSha = ${ currentSha } , hiddenBranch = ${ hiddenBranch } ` ,
275278 )
279+
276280 return new CheckpointService ( taskId , git , baseDir , currentBranch , currentSha , hiddenBranch , log )
277281 }
278282
@@ -284,16 +288,33 @@ export class CheckpointService {
284288 log ( `[initRepo] Initialized new Git repository at ${ baseDir } ` )
285289 }
286290
287- // Only set user config if not already configured
288- const userName = await git . getConfig ( "user.name" )
289- const userEmail = await git . getConfig ( "user.email" )
291+ const globalUserName = await git . getConfig ( "user.name" , "global" )
292+ const localUserName = await git . getConfig ( "user.name" , "local" )
293+ const userName = localUserName . value || globalUserName . value
294+
295+ const globalUserEmail = await git . getConfig ( "user.email" , "global" )
296+ const localUserEmail = await git . getConfig ( "user.email" , "local" )
297+ const userEmail = localUserEmail . value || globalUserEmail . value
298+
299+ // Prior versions of this service indiscriminately set the local user
300+ // config, and it should not override the global config. To address
301+ // this we remove the local user config if it matches the default
302+ // user name and email and there's a global config.
303+ if ( globalUserName . value && localUserName . value === CheckpointService . USER_NAME ) {
304+ await git . raw ( [ "config" , "--unset" , "--local" , "user.name" ] )
305+ }
306+
307+ if ( globalUserEmail . value && localUserEmail . value === CheckpointService . USER_EMAIL ) {
308+ await git . raw ( [ "config" , "--unset" , "--local" , "user.email" ] )
309+ }
290310
291- if ( ! userName . value ) {
292- await git . addConfig ( "user.name" , "Roo Code" )
311+ // Only set user config if not already configured.
312+ if ( ! userName ) {
313+ await git . addConfig ( "user.name" , CheckpointService . USER_NAME )
293314 }
294315
295- if ( ! userEmail . value ) {
296- await git . addConfig ( "user.email" , "[email protected] " ) 316+ if ( ! userEmail ) {
317+ await git . addConfig ( "user.email" , CheckpointService . USER_EMAIL )
297318 }
298319
299320 if ( ! isExistingRepo ) {
0 commit comments