Skip to content

Commit c501370

Browse files
committed
Make sure to push to source branch and not empty HEAD
1 parent 739ac64 commit c501370

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)