Skip to content

Commit 739ac64

Browse files
committed
Remove duplciate code
1 parent 168c5e4 commit 739ac64

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

Tasks/UnityBuild/UnityBuildV3/unity-versioning.ts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,11 @@ export class UnityVersioning {
271271
projectVersioningCommitChangesMessageVariableName
272272
)!;
273273

274-
commitMessage = commitMessage
275-
.replace(
276-
/{{bundleVersion}}/g,
277-
`${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}`
278-
)
279-
.replace(/{{buildNumber}}/g, buildCode.toString());
274+
commitMessage = this.replacePlaceholders(
275+
commitMessage,
276+
bundleVersion,
277+
buildCode
278+
);
280279

281280
tl.execSync("git", ["config", "user.name", commitChangesUserName]);
282281
tl.execSync("git", ["config", "user.email", commitChangesUserMail]);
@@ -290,12 +289,11 @@ export class UnityVersioning {
290289
true
291290
)!;
292291

293-
gitTag = createTagPattern
294-
.replace(
295-
/{{bundleVersion}}/g,
296-
`${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}`
297-
)
298-
.replace(/{{buildNumber}}/g, buildCode.toString());
292+
gitTag = this.replacePlaceholders(
293+
createTagPattern,
294+
bundleVersion,
295+
buildCode
296+
);
299297

300298
tl.execSync("git", ["tag", gitTag]);
301299
}
@@ -322,4 +320,17 @@ export class UnityVersioning {
322320

323321
return 0;
324322
}
323+
324+
private static replacePlaceholders(
325+
input: string,
326+
bundleVersion: SemanticVersion,
327+
buildCode: number
328+
): string {
329+
return input
330+
.replace(
331+
/{{bundleVersion}}/g,
332+
`${bundleVersion.major}.${bundleVersion.minor}.${bundleVersion.patch}`
333+
)
334+
.replace(/{{buildNumber}}/g, buildCode.toString());
335+
}
325336
}

0 commit comments

Comments
 (0)