@@ -277,6 +277,14 @@ export class UnityVersioning {
277277 buildCode
278278 ) ;
279279
280+ // Since Azure Pipelines will by default to a shallow clone
281+ // we must first explicitly switch to the source branch prior to commiting
282+ // changes and pushing.
283+ const sourceBranchName = tl . getVariable ( "Build.SourceBranchName" ) ! ;
284+ tl . execSync ( "git" , [ "fetch" , `origin ${ sourceBranchName } ` ] ) ;
285+ tl . execSync ( "git" , [ "checkout" , sourceBranchName ] ) ;
286+
287+ // Now we can commit the changes.
280288 tl . execSync ( "git" , [ "config" , "user.name" , commitChangesUserName ] ) ;
281289 tl . execSync ( "git" , [ "config" , "user.email" , commitChangesUserMail ] ) ;
282290 tl . execSync ( "git" , [ "add" , "." ] ) ;
@@ -298,6 +306,7 @@ export class UnityVersioning {
298306 tl . execSync ( "git" , [ "tag" , gitTag ] ) ;
299307 }
300308
309+ // Finally push the changeset and tag, if created.
301310 tl . execSync ( "git" , [ "push" , "origin HEAD" ] ) ;
302311 if ( createTag ) {
303312 tl . execSync ( "git" , [ "push" , "origin" , gitTag ] ) ;
0 commit comments