microsoft/typespec

Public

mirrored from https://github.com/microsoft/typespecAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
6357dc0d0e1fb00a591a2a8aaf243804d727e52b

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

eng/common/scripts/resolve-target-branch.js

23lines · modecode

1// @ts-check
2const prTargetBranch = process.env["SYSTEM_PULLREQUEST_TARGETBRANCHNAME"];
3const currentBranch = process.env["BUILD_SOURCEBRANCH"];
4
5console.log("Branches:", {
6 prTargetBranch,
7 currentBranch,
8});
9
10if (prTargetBranch !== undefined) {
11 console.log("Target branch is", prTargetBranch);
12 console.log(`##vso[task.setvariable variable=TARGET_BRANCH]${prTargetBranch}`);
13} else if (currentBranch) {
14 const match = currentBranch.match(/refs\/heads\/gh-readonly-queue\/(.*)\/pr-.*/);
15 if (match !== null) {
16 const targetBranch = match[1];
17 console.log("Target branch is", targetBranch);
18 console.log(`##vso[task.setvariable variable=TARGET_BRANCH]${targetBranch}`);
19 }
20} else {
21 console.log("Failed to resolve target branch.");
22 process.exit(1);
23}
24