threadlines 0.1.15 ā 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/check.js +30 -44
- package/dist/git/repo.js +35 -49
- package/dist/utils/ci-detection.js +17 -74
- package/package.json +1 -1
package/dist/commands/check.js
CHANGED
|
@@ -48,33 +48,26 @@ const fs = __importStar(require("fs"));
|
|
|
48
48
|
const path = __importStar(require("path"));
|
|
49
49
|
const chalk_1 = __importDefault(require("chalk"));
|
|
50
50
|
/**
|
|
51
|
-
* Detect the environment where the check is being run
|
|
52
|
-
*
|
|
51
|
+
* Detect the environment where the check is being run.
|
|
52
|
+
*
|
|
53
|
+
* CI Environment Detection:
|
|
54
|
+
* - Vercel: VERCEL=1
|
|
55
|
+
* - GitHub Actions: GITHUB_ACTIONS=1
|
|
56
|
+
* - GitLab CI: GITLAB_CI=1 or (CI=1 + CI_COMMIT_SHA)
|
|
57
|
+
* - Local: None of the above
|
|
58
|
+
*
|
|
59
|
+
* Available CI Environment Variables:
|
|
60
|
+
* - GitHub Actions: GITHUB_REPOSITORY, GITHUB_REF_NAME, GITHUB_SHA, GITHUB_BASE_REF, GITHUB_HEAD_REF
|
|
61
|
+
* - Vercel: VERCEL_GIT_REPO_OWNER, VERCEL_GIT_REPO_SLUG, VERCEL_GIT_COMMIT_REF, VERCEL_GIT_COMMIT_SHA
|
|
62
|
+
* - GitLab CI: CI_COMMIT_REF_NAME, CI_COMMIT_SHA, CI_MERGE_REQUEST_IID, CI_MERGE_REQUEST_TITLE
|
|
53
63
|
*/
|
|
54
64
|
function detectEnvironment() {
|
|
55
|
-
|
|
56
|
-
console.log(chalk_1.default.gray(` [DEBUG] detectEnvironment: VERCEL = "${process.env.VERCEL || 'NOT SET'}"`));
|
|
57
|
-
console.log(chalk_1.default.gray(` [DEBUG] detectEnvironment: GITHUB_ACTIONS = "${process.env.GITHUB_ACTIONS || 'NOT SET'}"`));
|
|
58
|
-
console.log(chalk_1.default.gray(` [DEBUG] detectEnvironment: GITLAB_CI = "${process.env.GITLAB_CI || 'NOT SET'}"`));
|
|
59
|
-
console.log(chalk_1.default.gray(` [DEBUG] detectEnvironment: CI = "${process.env.CI || 'NOT SET'}"`));
|
|
60
|
-
console.log(chalk_1.default.gray(` [DEBUG] detectEnvironment: CI_COMMIT_SHA = "${process.env.CI_COMMIT_SHA || 'NOT SET'}"`));
|
|
61
|
-
// Vercel: VERCEL env var is always set in Vercel builds
|
|
62
|
-
if (process.env.VERCEL) {
|
|
63
|
-
console.log(chalk_1.default.green(' [DEBUG] detectEnvironment: Detected VERCEL'));
|
|
65
|
+
if (process.env.VERCEL)
|
|
64
66
|
return 'vercel';
|
|
65
|
-
|
|
66
|
-
// GitHub Actions: GITHUB_ACTIONS env var is always set
|
|
67
|
-
if (process.env.GITHUB_ACTIONS) {
|
|
68
|
-
console.log(chalk_1.default.green(' [DEBUG] detectEnvironment: Detected GITHUB_ACTIONS'));
|
|
67
|
+
if (process.env.GITHUB_ACTIONS)
|
|
69
68
|
return 'github';
|
|
70
|
-
|
|
71
|
-
// GitLab CI: GITLAB_CI env var is always set, or CI is set with GitLab-specific vars
|
|
72
|
-
if (process.env.GITLAB_CI || (process.env.CI && process.env.CI_COMMIT_SHA)) {
|
|
73
|
-
console.log(chalk_1.default.green(' [DEBUG] detectEnvironment: Detected GITLAB_CI'));
|
|
69
|
+
if (process.env.GITLAB_CI || (process.env.CI && process.env.CI_COMMIT_SHA))
|
|
74
70
|
return 'gitlab';
|
|
75
|
-
}
|
|
76
|
-
// Local development: none of the above
|
|
77
|
-
console.log(chalk_1.default.yellow(' [DEBUG] detectEnvironment: No CI env vars detected - returning "local"'));
|
|
78
71
|
return 'local';
|
|
79
72
|
}
|
|
80
73
|
async function checkCommand(options) {
|
|
@@ -180,6 +173,19 @@ async function checkCommand(options) {
|
|
|
180
173
|
console.log(chalk_1.default.gray(`š Collecting git changes for branch: ${autoTarget.value}...`));
|
|
181
174
|
gitDiff = await (0, diff_1.getBranchDiff)(repoRoot, autoTarget.value);
|
|
182
175
|
reviewContext = { type: 'branch', value: autoTarget.value };
|
|
176
|
+
// Capture commit SHA from CI env vars if available
|
|
177
|
+
if (process.env.GITHUB_SHA) {
|
|
178
|
+
commitSha = process.env.GITHUB_SHA;
|
|
179
|
+
const message = await (0, diff_1.getCommitMessage)(repoRoot, process.env.GITHUB_SHA);
|
|
180
|
+
if (message)
|
|
181
|
+
commitMessage = message;
|
|
182
|
+
}
|
|
183
|
+
else if (process.env.VERCEL_GIT_COMMIT_SHA) {
|
|
184
|
+
commitSha = process.env.VERCEL_GIT_COMMIT_SHA;
|
|
185
|
+
const message = await (0, diff_1.getCommitMessage)(repoRoot, process.env.VERCEL_GIT_COMMIT_SHA);
|
|
186
|
+
if (message)
|
|
187
|
+
commitMessage = message;
|
|
188
|
+
}
|
|
183
189
|
}
|
|
184
190
|
else if (autoTarget.type === 'commit') {
|
|
185
191
|
// Commit: use single commit
|
|
@@ -242,16 +248,6 @@ async function checkCommand(options) {
|
|
|
242
248
|
};
|
|
243
249
|
});
|
|
244
250
|
// 4. Get repo name and branch name
|
|
245
|
-
console.log(chalk_1.default.gray('\nš” Detecting repository and branch information...'));
|
|
246
|
-
// Log Vercel-specific env vars that might help with repo detection
|
|
247
|
-
if (process.env.VERCEL) {
|
|
248
|
-
console.log(chalk_1.default.gray(' [DEBUG] Vercel environment variables:'));
|
|
249
|
-
console.log(chalk_1.default.gray(` [DEBUG] VERCEL_GIT_REPO_OWNER = "${process.env.VERCEL_GIT_REPO_OWNER || 'NOT SET'}"`));
|
|
250
|
-
console.log(chalk_1.default.gray(` [DEBUG] VERCEL_GIT_REPO_SLUG = "${process.env.VERCEL_GIT_REPO_SLUG || 'NOT SET'}"`));
|
|
251
|
-
console.log(chalk_1.default.gray(` [DEBUG] VERCEL_GIT_REPO_ID = "${process.env.VERCEL_GIT_REPO_ID || 'NOT SET'}"`));
|
|
252
|
-
console.log(chalk_1.default.gray(` [DEBUG] VERCEL_GIT_COMMIT_REF = "${process.env.VERCEL_GIT_COMMIT_REF || 'NOT SET'}"`));
|
|
253
|
-
console.log(chalk_1.default.gray(` [DEBUG] VERCEL_GIT_COMMIT_SHA = "${process.env.VERCEL_GIT_COMMIT_SHA || 'NOT SET'}"`));
|
|
254
|
-
}
|
|
255
251
|
const repoName = await (0, repo_1.getRepoName)(repoRoot);
|
|
256
252
|
const branchName = await (0, repo_1.getBranchName)(repoRoot);
|
|
257
253
|
// 5. Get API URL
|
|
@@ -259,19 +255,9 @@ async function checkCommand(options) {
|
|
|
259
255
|
process.env.THREADLINE_API_URL ||
|
|
260
256
|
'https://devthreadline.com';
|
|
261
257
|
// 6. Detect environment
|
|
262
|
-
console.log(chalk_1.default.gray('\nš Detecting environment...'));
|
|
263
258
|
const environment = detectEnvironment();
|
|
264
|
-
// 7.
|
|
265
|
-
console.log(chalk_1.default.gray('
|
|
266
|
-
console.log(chalk_1.default.gray(` repoName: ${repoName ? `"${repoName}"` : 'null/undefined'}`));
|
|
267
|
-
console.log(chalk_1.default.gray(` branchName: ${branchName ? `"${branchName}"` : 'null/undefined'}`));
|
|
268
|
-
console.log(chalk_1.default.gray(` commitSha: ${commitSha ? `"${commitSha}"` : 'null/undefined'}`));
|
|
269
|
-
console.log(chalk_1.default.gray(` commitMessage: ${commitMessage ? `"${commitMessage.substring(0, 50)}..."` : 'null/undefined'}`));
|
|
270
|
-
console.log(chalk_1.default.gray(` prTitle: ${prTitle ? `"${prTitle}"` : 'null/undefined'}`));
|
|
271
|
-
console.log(chalk_1.default.gray(` environment: "${environment}"`));
|
|
272
|
-
console.log(chalk_1.default.gray(` reviewContext: ${JSON.stringify(reviewContext)}`));
|
|
273
|
-
// 8. Call review API
|
|
274
|
-
console.log(chalk_1.default.gray('\nš¤ Running threadline checks...'));
|
|
259
|
+
// 7. Call review API
|
|
260
|
+
console.log(chalk_1.default.gray('š¤ Running threadline checks...'));
|
|
275
261
|
const client = new client_1.ReviewAPIClient(apiUrl);
|
|
276
262
|
const response = await client.review({
|
|
277
263
|
threadlines: threadlinesWithContext,
|
package/dist/git/repo.js
CHANGED
|
@@ -6,72 +6,58 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getRepoName = getRepoName;
|
|
7
7
|
exports.getBranchName = getBranchName;
|
|
8
8
|
const simple_git_1 = __importDefault(require("simple-git"));
|
|
9
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
10
9
|
/**
|
|
11
|
-
* Gets
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Gets repository URL. Prefers CI environment variables over git commands.
|
|
11
|
+
*
|
|
12
|
+
* CI Environment Variables:
|
|
13
|
+
* - GitHub Actions: GITHUB_REPOSITORY (format: "owner/repo"), GITHUB_SERVER_URL
|
|
14
|
+
* - Vercel: VERCEL_GIT_REPO_OWNER, VERCEL_GIT_REPO_SLUG
|
|
15
|
+
* - GitLab CI: Not available (falls back to git)
|
|
16
|
+
* - Local: Falls back to git origin remote
|
|
14
17
|
*/
|
|
15
18
|
async function getRepoName(repoRoot) {
|
|
19
|
+
// GitHub Actions: GITHUB_REPOSITORY = "owner/repo"
|
|
20
|
+
if (process.env.GITHUB_REPOSITORY) {
|
|
21
|
+
const serverUrl = process.env.GITHUB_SERVER_URL || 'https://github.com';
|
|
22
|
+
return `${serverUrl}/${process.env.GITHUB_REPOSITORY}.git`;
|
|
23
|
+
}
|
|
24
|
+
// Vercel: Construct from owner + slug
|
|
25
|
+
if (process.env.VERCEL_GIT_REPO_OWNER && process.env.VERCEL_GIT_REPO_SLUG) {
|
|
26
|
+
return `https://github.com/${process.env.VERCEL_GIT_REPO_OWNER}/${process.env.VERCEL_GIT_REPO_SLUG}.git`;
|
|
27
|
+
}
|
|
28
|
+
// Fallback: git origin remote (local dev, GitLab CI)
|
|
16
29
|
const git = (0, simple_git_1.default)(repoRoot);
|
|
17
|
-
console.log(chalk_1.default.gray(' [DEBUG] getRepoName: Starting...'));
|
|
18
|
-
console.log(chalk_1.default.gray(` [DEBUG] getRepoName: repoRoot = ${repoRoot}`));
|
|
19
30
|
try {
|
|
20
31
|
const remotes = await git.getRemotes(true);
|
|
21
|
-
console.log(chalk_1.default.gray(` [DEBUG] getRepoName: Found ${remotes.length} remote(s)`));
|
|
22
|
-
if (remotes.length > 0) {
|
|
23
|
-
remotes.forEach((remote, idx) => {
|
|
24
|
-
console.log(chalk_1.default.gray(` [DEBUG] getRepoName: Remote[${idx}] name="${remote.name}", fetch="${remote.refs?.fetch || 'N/A'}", push="${remote.refs?.push || 'N/A'}"`));
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
console.log(chalk_1.default.yellow(' [DEBUG] getRepoName: No remotes found'));
|
|
29
|
-
}
|
|
30
32
|
const origin = remotes.find(r => r.name === 'origin');
|
|
31
|
-
|
|
32
|
-
console.log(chalk_1.default.yellow(' [DEBUG] getRepoName: No "origin" remote found'));
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
console.log(chalk_1.default.gray(` [DEBUG] getRepoName: Found origin remote: fetch="${origin.refs?.fetch || 'N/A'}"`));
|
|
36
|
-
if (!origin.refs?.fetch) {
|
|
37
|
-
console.log(chalk_1.default.yellow(' [DEBUG] getRepoName: Origin remote found but no fetch URL'));
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
console.log(chalk_1.default.green(` [DEBUG] getRepoName: Success - returning "${origin.refs.fetch}"`));
|
|
41
|
-
// Return raw URL - let server handle normalization if needed
|
|
42
|
-
return origin.refs.fetch;
|
|
33
|
+
return origin?.refs?.fetch || null;
|
|
43
34
|
}
|
|
44
|
-
catch
|
|
45
|
-
console.log(chalk_1.default.red(` [DEBUG] getRepoName: Error occurred: ${error.message || error}`));
|
|
46
|
-
if (error.stack) {
|
|
47
|
-
console.log(chalk_1.default.gray(` [DEBUG] getRepoName: Stack: ${error.stack}`));
|
|
48
|
-
}
|
|
35
|
+
catch {
|
|
49
36
|
return null;
|
|
50
37
|
}
|
|
51
38
|
}
|
|
52
39
|
/**
|
|
53
|
-
* Gets
|
|
54
|
-
*
|
|
40
|
+
* Gets branch name. Prefers CI environment variables over git commands.
|
|
41
|
+
*
|
|
42
|
+
* CI Environment Variables:
|
|
43
|
+
* - GitHub Actions: GITHUB_REF_NAME
|
|
44
|
+
* - Vercel: VERCEL_GIT_COMMIT_REF
|
|
45
|
+
* - GitLab CI: CI_COMMIT_REF_NAME
|
|
46
|
+
* - Local: Falls back to git revparse --abbrev-ref HEAD
|
|
55
47
|
*/
|
|
56
48
|
async function getBranchName(repoRoot) {
|
|
49
|
+
if (process.env.GITHUB_REF_NAME)
|
|
50
|
+
return process.env.GITHUB_REF_NAME;
|
|
51
|
+
if (process.env.VERCEL_GIT_COMMIT_REF)
|
|
52
|
+
return process.env.VERCEL_GIT_COMMIT_REF;
|
|
53
|
+
if (process.env.CI_COMMIT_REF_NAME)
|
|
54
|
+
return process.env.CI_COMMIT_REF_NAME;
|
|
55
|
+
// Fallback: git command
|
|
57
56
|
const git = (0, simple_git_1.default)(repoRoot);
|
|
58
|
-
console.log(chalk_1.default.gray(' [DEBUG] getBranchName: Starting...'));
|
|
59
|
-
console.log(chalk_1.default.gray(` [DEBUG] getBranchName: repoRoot = ${repoRoot}`));
|
|
60
57
|
try {
|
|
61
|
-
|
|
62
|
-
console.log(chalk_1.default.gray(` [DEBUG] getBranchName: git revparse --abbrev-ref HEAD returned: "${branch || '(empty)'}"`));
|
|
63
|
-
if (!branch) {
|
|
64
|
-
console.log(chalk_1.default.yellow(' [DEBUG] getBranchName: Git command returned empty string'));
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
console.log(chalk_1.default.green(` [DEBUG] getBranchName: Success - returning "${branch}"`));
|
|
68
|
-
return branch;
|
|
58
|
+
return await git.revparse(['--abbrev-ref', 'HEAD']) || null;
|
|
69
59
|
}
|
|
70
|
-
catch
|
|
71
|
-
console.log(chalk_1.default.red(` [DEBUG] getBranchName: Error occurred: ${error.message || error}`));
|
|
72
|
-
if (error.stack) {
|
|
73
|
-
console.log(chalk_1.default.gray(` [DEBUG] getBranchName: Stack: ${error.stack}`));
|
|
74
|
-
}
|
|
60
|
+
catch {
|
|
75
61
|
return null;
|
|
76
62
|
}
|
|
77
63
|
}
|
|
@@ -1,42 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getAutoReviewTarget = getAutoReviewTarget;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
4
|
function getAutoReviewTarget() {
|
|
9
|
-
|
|
10
|
-
// Log ALL GitHub Actions env vars that start with GITHUB_ to see what's available
|
|
11
|
-
if (process.env.GITHUB_ACTIONS) {
|
|
12
|
-
console.log(chalk_1.default.gray(' [DEBUG] getAutoReviewTarget: All GITHUB_* env vars:'));
|
|
13
|
-
const githubVars = Object.keys(process.env)
|
|
14
|
-
.filter(key => key.startsWith('GITHUB_'))
|
|
15
|
-
.sort();
|
|
16
|
-
githubVars.forEach(key => {
|
|
17
|
-
const value = process.env[key];
|
|
18
|
-
// Truncate long values for readability
|
|
19
|
-
const displayValue = value && value.length > 100 ? value.substring(0, 100) + '...' : value;
|
|
20
|
-
console.log(chalk_1.default.gray(` ${key} = "${displayValue || 'NOT SET'}"`));
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
// 1. Check for PR/MR context (most authoritative)
|
|
24
|
-
// GitHub Actions PR
|
|
25
|
-
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: Checking GitHub Actions PR...`));
|
|
26
|
-
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: GITHUB_EVENT_NAME = "${process.env.GITHUB_EVENT_NAME || 'NOT SET'}"`));
|
|
5
|
+
// 1. PR/MR context
|
|
27
6
|
if (process.env.GITHUB_EVENT_NAME === 'pull_request') {
|
|
28
7
|
const targetBranch = process.env.GITHUB_BASE_REF;
|
|
29
8
|
const sourceBranch = process.env.GITHUB_HEAD_REF;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
process.env.GITHUB_EVENT_NUMBER;
|
|
34
|
-
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: GITHUB_BASE_REF = "${targetBranch || 'NOT SET'}"`));
|
|
35
|
-
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: GITHUB_HEAD_REF = "${sourceBranch || 'NOT SET'}"`));
|
|
36
|
-
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: GITHUB_EVENT_PULL_REQUEST_NUMBER = "${process.env.GITHUB_EVENT_PULL_REQUEST_NUMBER || 'NOT SET'}"`));
|
|
37
|
-
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: GITHUB_EVENT_NUMBER = "${process.env.GITHUB_EVENT_NUMBER || 'NOT SET'}"`));
|
|
9
|
+
const prNumber = process.env.GITHUB_EVENT_PULL_REQUEST_NUMBER || process.env.GITHUB_EVENT_NUMBER;
|
|
10
|
+
// Log PR detection for verification (remove after confirming it works)
|
|
11
|
+
console.log(`[PR Detection] GITHUB_BASE_REF=${targetBranch || 'NOT SET'}, GITHUB_HEAD_REF=${sourceBranch || 'NOT SET'}, PR_NUMBER=${prNumber || 'NOT SET'}`);
|
|
38
12
|
if (targetBranch && sourceBranch && prNumber) {
|
|
39
|
-
console.log(chalk_1.default.green(` [DEBUG] getAutoReviewTarget: Detected GitHub PR #${prNumber}`));
|
|
40
13
|
return {
|
|
41
14
|
type: 'pr',
|
|
42
15
|
value: prNumber,
|
|
@@ -44,66 +17,36 @@ function getAutoReviewTarget() {
|
|
|
44
17
|
targetBranch
|
|
45
18
|
};
|
|
46
19
|
}
|
|
47
|
-
else {
|
|
48
|
-
console.log(chalk_1.default.yellow(' [DEBUG] getAutoReviewTarget: GitHub PR env vars incomplete'));
|
|
49
|
-
}
|
|
50
20
|
}
|
|
51
|
-
// GitLab CI MR
|
|
52
|
-
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: Checking GitLab CI MR...`));
|
|
53
|
-
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: CI_MERGE_REQUEST_IID = "${process.env.CI_MERGE_REQUEST_IID || 'NOT SET'}"`));
|
|
54
21
|
if (process.env.CI_MERGE_REQUEST_IID) {
|
|
55
22
|
const targetBranch = process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME;
|
|
56
23
|
const sourceBranch = process.env.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME;
|
|
57
24
|
const mrNumber = process.env.CI_MERGE_REQUEST_IID;
|
|
58
|
-
const mrTitle = process.env.CI_MERGE_REQUEST_TITLE;
|
|
59
|
-
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "${targetBranch || 'NOT SET'}"`));
|
|
60
|
-
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: CI_MERGE_REQUEST_SOURCE_BRANCH_NAME = "${sourceBranch || 'NOT SET'}"`));
|
|
61
|
-
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: CI_MERGE_REQUEST_TITLE = "${mrTitle || 'NOT SET'}"`));
|
|
25
|
+
const mrTitle = process.env.CI_MERGE_REQUEST_TITLE;
|
|
62
26
|
if (targetBranch && sourceBranch && mrNumber) {
|
|
63
|
-
console.log(chalk_1.default.green(` [DEBUG] getAutoReviewTarget: Detected GitLab MR #${mrNumber}`));
|
|
64
27
|
return {
|
|
65
28
|
type: 'mr',
|
|
66
29
|
value: mrNumber,
|
|
67
30
|
sourceBranch,
|
|
68
31
|
targetBranch,
|
|
69
|
-
prTitle: mrTitle || undefined
|
|
32
|
+
prTitle: mrTitle || undefined
|
|
70
33
|
};
|
|
71
34
|
}
|
|
72
|
-
else {
|
|
73
|
-
console.log(chalk_1.default.yellow(' [DEBUG] getAutoReviewTarget: GitLab MR env vars incomplete'));
|
|
74
|
-
}
|
|
75
35
|
}
|
|
76
|
-
// 2.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: VERCEL_GIT_COMMIT_REF = "${process.env.VERCEL_GIT_COMMIT_REF || 'NOT SET'}"`));
|
|
81
|
-
const branch = process.env.GITHUB_REF_NAME || // GitHub Actions
|
|
82
|
-
process.env.CI_COMMIT_REF_NAME || // GitLab CI
|
|
83
|
-
process.env.VERCEL_GIT_COMMIT_REF; // Vercel
|
|
36
|
+
// 2. Branch name
|
|
37
|
+
const branch = process.env.GITHUB_REF_NAME ||
|
|
38
|
+
process.env.CI_COMMIT_REF_NAME ||
|
|
39
|
+
process.env.VERCEL_GIT_COMMIT_REF;
|
|
84
40
|
if (branch) {
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
type: 'branch',
|
|
88
|
-
value: branch
|
|
89
|
-
};
|
|
41
|
+
return { type: 'branch', value: branch };
|
|
90
42
|
}
|
|
91
|
-
// 3.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: VERCEL_GIT_COMMIT_SHA = "${process.env.VERCEL_GIT_COMMIT_SHA || 'NOT SET'}"`));
|
|
96
|
-
const commit = process.env.GITHUB_SHA || // GitHub Actions
|
|
97
|
-
process.env.CI_COMMIT_SHA || // GitLab CI
|
|
98
|
-
process.env.VERCEL_GIT_COMMIT_SHA; // Vercel
|
|
43
|
+
// 3. Commit SHA
|
|
44
|
+
const commit = process.env.GITHUB_SHA ||
|
|
45
|
+
process.env.CI_COMMIT_SHA ||
|
|
46
|
+
process.env.VERCEL_GIT_COMMIT_SHA;
|
|
99
47
|
if (commit) {
|
|
100
|
-
|
|
101
|
-
return {
|
|
102
|
-
type: 'commit',
|
|
103
|
-
value: commit
|
|
104
|
-
};
|
|
48
|
+
return { type: 'commit', value: commit };
|
|
105
49
|
}
|
|
106
|
-
// 4. Local development
|
|
107
|
-
console.log(chalk_1.default.yellow(' [DEBUG] getAutoReviewTarget: No CI env vars detected - returning null (local mode)'));
|
|
50
|
+
// 4. Local development
|
|
108
51
|
return null;
|
|
109
52
|
}
|