Skip to content

Commit 8828eea

Browse files
committed
fix non git info
1 parent 85c0c7e commit 8828eea

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/lib/git.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ function executeCommand(command: string): string {
1717
}
1818
}
1919

20-
export function isGitRepo(): boolean {
20+
export function isGitRepo(ctx: Context): boolean {
2121
try {
2222
executeCommand('git status')
2323
return true
2424
} catch (error) {
25+
setNonGitInfo(ctx)
2526
return false
2627
}
2728
}
@@ -82,3 +83,25 @@ export default (ctx: Context): Git => {
8283
};
8384
}
8485
}
86+
87+
88+
function setNonGitInfo(ctx: Context) {
89+
let branch = ctx.env.CURRENT_BRANCH || 'unknown-branch'
90+
if (ctx.options.markBaseline) {
91+
ctx.env.BASELINE_BRANCH = branch
92+
ctx.env.SMART_GIT = false
93+
}
94+
let githubURL;
95+
if (ctx.options.githubURL && ctx.options.githubURL.startsWith('https://')) {
96+
githubURL = ctx.options.githubURL;
97+
}
98+
99+
ctx.git = {
100+
branch: branch,
101+
commitId: '-',
102+
commitAuthor: '-',
103+
commitMessage: '-',
104+
githubURL: githubURL? githubURL : '',
105+
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ''
106+
}
107+
}

src/tasks/getGitInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
77
return {
88
title: `Fetching git repo details`,
99
skip: (ctx): string => {
10-
return (!isGitRepo() && !ctx.env.SMARTUI_GIT_INFO_FILEPATH) ? '[SKIPPED] Fetching git repo details; not a git repo' : '';
10+
return (!isGitRepo(ctx) && !ctx.env.SMARTUI_GIT_INFO_FILEPATH) ? '[SKIPPED] Fetching git repo details; not a git repo' : '';
1111
},
1212
task: async (ctx, task): Promise<void> => {
1313
if (ctx.env.CURRENT_BRANCH && ctx.env.CURRENT_BRANCH.trim() === '') {

0 commit comments

Comments
 (0)