File tree Expand file tree Collapse file tree 3 files changed +59
-4
lines changed
Expand file tree Collapse file tree 3 files changed +59
-4
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,25 @@ function decode(attr) {
2929 * @returns {string } The current branch name or 'main' if detection fails
3030 */
3131function 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+ return fromEnv ;
49+ }
50+
3251 try {
3352 // Run git command to get current branch
3453 const branch = execSync ( "git rev-parse --abbrev-ref HEAD" , {
@@ -129,8 +148,8 @@ const plugin = function (babel, options = {}) {
129148 } = options ;
130149
131150 // Always use auto-detected values
132- const repoName = currentRepoName ;
133- const branch = currentBranch ;
151+ const repoName = options . repo_name ? options . repo_name : currentRepoName ;
152+ const branch = options . branch_name ? options . branch_name : currentBranch ;
134153
135154 return {
136155 name : "babel-plugin-codepress-html" ,
Original file line number Diff line number Diff line change @@ -34,6 +34,24 @@ function decode(attr) {
3434 * @returns {string } The current branch name or 'main' if detection fails
3535 */
3636function 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+ return fromEnv ;
54+ }
3755 try {
3856 // Run git command to get current branch
3957 const branch = execSync ( "git rev-parse --abbrev-ref HEAD" , {
@@ -134,8 +152,8 @@ const plugin = function (babel, options = {}) {
134152 } = options ;
135153
136154 // Always use auto-detected values
137- const repoName = currentRepoName ;
138- const branch = currentBranch ;
155+ const repoName = options . repo_name ? options . repo_name : currentRepoName ;
156+ const branch = options . branch_name ? options . branch_name : currentBranch ;
139157
140158 return {
141159 name : "babel-plugin-codepress-html" ,
Original file line number Diff line number Diff line change @@ -6,6 +6,24 @@ const path = require("path");
66 * @returns {string|null } The current branch name or null if detection fails
77 */
88function 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+ return fromEnv ;
26+ }
927 try {
1028 const branch = execSync ( "git rev-parse --abbrev-ref HEAD" , {
1129 encoding : "utf8" ,
You can’t perform that action at this time.
0 commit comments