Skip to content

Commit 0022acb

Browse files
Merge pull request #94 from LambdaTest/stage
Stage to main sync
2 parents aa9ef73 + 3507392 commit 0022acb

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-cli",
3-
"version": "3.0.9",
3+
"version": "3.0.10",
44
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
55
"files": [
66
"dist/**/*"

src/lib/env.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export default (): Env => {
1212
GITHUB_ACTIONS,
1313
FIGMA_TOKEN,
1414
LT_USERNAME,
15-
LT_ACCESS_KEY
15+
LT_ACCESS_KEY,
16+
BASELINE_BRANCH,
17+
CURRENT_BRANCH
1618
} = process.env
1719

1820
return {
@@ -26,6 +28,8 @@ export default (): Env => {
2628
GITHUB_ACTIONS,
2729
FIGMA_TOKEN,
2830
LT_USERNAME,
29-
LT_ACCESS_KEY
31+
LT_ACCESS_KEY,
32+
BASELINE_BRANCH,
33+
CURRENT_BRANCH,
3034
}
3135
}

src/lib/git.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ export default (ctx: Context): Git => {
3131
let gitInfo = JSON.parse(fs.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, 'utf-8'));
3232

3333
return {
34-
branch: gitInfo.branch || '',
34+
branch: ctx.env.CURRENT_BRANCH || gitInfo.branch || '',
3535
commitId: gitInfo.commit_id.slice(0,6) || '',
3636
commitMessage: gitInfo.commit_body || '',
3737
commitAuthor: gitInfo.commit_author || '',
38-
githubURL: (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : ''
38+
githubURL: (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : '',
39+
baselineBranch: ctx.env.BASELINE_BRANCH || ''
3940
}
4041
} else {
4142
const splitCharacter = '<##>';
@@ -48,15 +49,16 @@ export default (ctx: Context): Git => {
4849

4950
// e.g. master\n or master\nv1.1\n or master\nv1.1\nv1.2\n
5051
var branchAndTags = res[res.length-1].split('\n').filter(n => n);
51-
var branch = branchAndTags[0];
52+
var branch = ctx.env.CURRENT_BRANCH || branchAndTags[0];
5253
var tags = branchAndTags.slice(1);
5354

5455
return {
5556
branch: branch || '',
5657
commitId: res[0] || '',
5758
commitMessage: res[2] || '',
5859
commitAuthor: res[7] || '',
59-
githubURL: (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : ''
60+
githubURL: (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : '',
61+
baselineBranch: ctx.env.BASELINE_BRANCH || ''
6062
};
6163
}
6264
}

src/tasks/getGitInfo.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
1010
return (!isGitRepo() && !ctx.env.SMARTUI_GIT_INFO_FILEPATH) ? '[SKIPPED] Fetching git repo details; not a git repo' : '';
1111
},
1212
task: async (ctx, task): Promise<void> => {
13+
if (ctx.env.CURRENT_BRANCH && ctx.env.CURRENT_BRANCH.trim() === '') {
14+
throw new Error('Error: The environment variable CURRENT_BRANCH cannot be empty.');
15+
}
1316
try {
1417
ctx.git = getGitInfo(ctx);
1518
task.output = chalk.gray(`branch: ${ctx.git.branch}, commit: ${ctx.git.commitId}, author: ${ctx.git.commitAuthor}`);

src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export interface Env {
4848
FIGMA_TOKEN: string | undefined;
4949
LT_USERNAME : string | undefined;
5050
LT_ACCESS_KEY : string | undefined;
51+
BASELINE_BRANCH: string | undefined;
52+
CURRENT_BRANCH: string | undefined;
5153
}
5254

5355
export interface Snapshot {
@@ -93,6 +95,7 @@ export interface Git {
9395
commitAuthor: string;
9496
commitMessage: string;
9597
githubURL?: string;
98+
baselineBranch?: string;
9699
}
97100

98101
export interface Build {

0 commit comments

Comments
 (0)