Skip to content

Commit c1ec623

Browse files
committed
I think these are all the changes from swc-build but I might have missed something
1 parent b743aec commit c1ec623

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

babel/index.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ function decode(attr) {
2929
* @returns {string} The current branch name or 'main' if detection fails
3030
*/
3131
function detectGitBranch() {
32+
const fromEnv =
33+
process.env.GIT_BRANCH ||
34+
// Vercel
35+
process.env.VERCEL_GIT_COMMIT_REF ||
36+
// GitHub Actions (PRs use GITHUB_HEAD_REF, pushes use GITHUB_REF_NAME)
37+
process.env.GITHUB_HEAD_REF ||
38+
process.env.GITHUB_REF_NAME ||
39+
// GitLab CI
40+
process.env.CI_COMMIT_REF_NAME ||
41+
// CircleCI
42+
process.env.CIRCLE_BRANCH ||
43+
// Bitbucket Pipelines
44+
process.env.BITBUCKET_BRANCH ||
45+
// Netlify
46+
process.env.BRANCH;
47+
if (fromEnv) {
48+
console.info(`Using branch from env ${fromEnv}`);
49+
return fromEnv;
50+
}
51+
3252
try {
3353
// Run git command to get current branch
3454
const branch = execSync("git rev-parse --abbrev-ref HEAD", {
@@ -129,8 +149,8 @@ const plugin = function (babel, options = {}) {
129149
} = options;
130150

131151
// Always use auto-detected values
132-
const repoName = currentRepoName;
133-
const branch = currentBranch;
152+
const repoName = options.repo_name ? options.repo_name : currentRepoName;
153+
const branch = options.branch_name ? options.branch_name : currentRepoName;
134154

135155
return {
136156
name: "babel-plugin-codepress-html",

src/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,25 @@ function decode(attr) {
3434
* @returns {string} The current branch name or 'main' if detection fails
3535
*/
3636
function detectGitBranch() {
37+
const fromEnv =
38+
process.env.GIT_BRANCH ||
39+
// Vercel
40+
process.env.VERCEL_GIT_COMMIT_REF ||
41+
// GitHub Actions (PRs use GITHUB_HEAD_REF, pushes use GITHUB_REF_NAME)
42+
process.env.GITHUB_HEAD_REF ||
43+
process.env.GITHUB_REF_NAME ||
44+
// GitLab CI
45+
process.env.CI_COMMIT_REF_NAME ||
46+
// CircleCI
47+
process.env.CIRCLE_BRANCH ||
48+
// Bitbucket Pipelines
49+
process.env.BITBUCKET_BRANCH ||
50+
// Netlify
51+
process.env.BRANCH;
52+
if (fromEnv) {
53+
console.info(`Using branch from env ${fromEnv}`);
54+
return fromEnv;
55+
}
3756
try {
3857
// Run git command to get current branch
3958
const branch = execSync("git rev-parse --abbrev-ref HEAD", {

swc/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ const path = require("path");
66
* @returns {string|null} The current branch name or null if detection fails
77
*/
88
function detectGitBranch() {
9+
const fromEnv =
10+
process.env.GIT_BRANCH ||
11+
// Vercel
12+
process.env.VERCEL_GIT_COMMIT_REF ||
13+
// GitHub Actions (PRs use GITHUB_HEAD_REF, pushes use GITHUB_REF_NAME)
14+
process.env.GITHUB_HEAD_REF ||
15+
process.env.GITHUB_REF_NAME ||
16+
// GitLab CI
17+
process.env.CI_COMMIT_REF_NAME ||
18+
// CircleCI
19+
process.env.CIRCLE_BRANCH ||
20+
// Bitbucket Pipelines
21+
process.env.BITBUCKET_BRANCH ||
22+
// Netlify
23+
process.env.BRANCH;
24+
if (fromEnv) {
25+
console.info(`Using branch from env ${fromEnv}`);
26+
return fromEnv;
27+
}
928
try {
1029
const branch = execSync("git rev-parse --abbrev-ref HEAD", {
1130
encoding: "utf8",

0 commit comments

Comments
 (0)