Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More fixes about Flow Git Diff & Doc #957

Merged
merged 5 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions defaults/monitoring/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

variables:
FORCE_COLOR: "1"
GIT_FETCH_EXTRA_FLAGS: --depth 10000

# Pipeline stages
stages:
Expand Down
2 changes: 1 addition & 1 deletion src/common/gitProvider/utilsMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export async function flowDiffToMarkdownForPullRequest(flowNames: string[], from
await generateDiffMarkdownWithSvg(fileMetadata, fromCommit, toCommit, flowDiffMarkdownList, flowName);
}
} catch (e: any) {
uxLog(this, c.yellow(`[FlowGitDiff] Unable to generate Flow diff: ${e.message}`));
uxLog(this, c.yellow(`[FlowGitDiff] Unable to generate Flow diff for ${flowName}: ${e.message}`));
const flowGenErrorMd = `# ${flowName}

Error while generating Flows visual git diff
Expand Down
2 changes: 2 additions & 0 deletions src/common/utils/deployUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ async function getDeploymentId(rawLog: string) {
if (jsonLog) {
const deploymentId = jsonLog?.result?.id || null;
if (deploymentId) {
globalThis.pullRequestDeploymentId = deploymentId;
return deploymentId;
}
}
Expand All @@ -448,6 +449,7 @@ async function getDeploymentId(rawLog: string) {
globalThis.pullRequestDeploymentId = deploymentId;
return deploymentId;
}
uxLog(this, c.yellow(`Unable to find deploymentId in logs \n${c.grey(rawLog)}`));
return null;
}

Expand Down
12 changes: 12 additions & 0 deletions src/common/utils/flowVisualiser/nodeFormatUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@ const FIELDS_WITH_VALUES_TO_FORMAT = [
"type"
];

const FIELDS_WITH_VALUES_TO_FORMAT_ENUM = {
"status": {
"Draft": "⚠️ Draft",
"Inactive": "⚠️ Inactive",
"InvalidDraft": "⚠️ Invalid Draft"
}
}

const FIELDS_PREFERRED_ORDER_START = [
"type",
"object",
"processType",
"triggerType",
"recordTriggerType",
"label",
"status",
"actionType",
"actionName",
"dataType",
Expand Down Expand Up @@ -338,6 +347,9 @@ export function stringifyValue(valueIn: any, field: string, allProperties: strin
if (allProperties.includes(valueStringified)) {
valueStringified = `[${valueStringified}](#${valueStringified.toLowerCase()})`
}
else if (FIELDS_WITH_VALUES_TO_FORMAT_ENUM[field] && FIELDS_WITH_VALUES_TO_FORMAT_ENUM[field][valueStringified]) {
valueStringified = FIELDS_WITH_VALUES_TO_FORMAT_ENUM[field][valueStringified];
}
else if (FIELDS_WITH_VALUES_TO_FORMAT.includes(field)) {
valueStringified = prettifyFieldName(valueStringified);
if (field === "type" && valueStringified.endsWith("s")) {
Expand Down
14 changes: 10 additions & 4 deletions src/common/utils/gitUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getConfig } from '../../config/index.js';
import { prompts } from './prompts.js';
import c from 'chalk';
import fs from "fs-extra";
import * as path from "path";
import sortArray from 'sort-array';
import {
Expand Down Expand Up @@ -186,8 +187,13 @@ export async function computeCommitsSummary(checkOnly, pullRequestInfo: any) {
const updatedFiles = await getCommitUpdatedFiles(logResult.hash);
for (const updatedFile of updatedFiles) {
if (updatedFile.endsWith(".flow-meta.xml")) {
const flowName = path.basename(updatedFile, ".flow-meta.xml");
flowList.push(flowName);
if (fs.existsSync(updatedFile)) {
const flowName = path.basename(updatedFile, ".flow-meta.xml");
flowList.push(flowName);
}
else {
uxLog(this, c.yellow(`[FlowGitDiff] Unable to find Flow file ${updatedFile} (probably has been deleted)`));
}
}
}
}
Expand All @@ -214,9 +220,9 @@ async function collectTicketsAndManualActions(str: string, tickets: Ticket[], ma
}

export async function getCommitUpdatedFiles(commitHash) {
const result = await git().show(["--name-only", commitHash]);
const result = await git().show(["--name-only", "--pretty=format:", commitHash]);
// Split the result into lines (file paths) and remove empty lines
const files = result.split('\n').filter(file => file.trim() !== '');
const files = result.split('\n').filter(file => file.trim() !== '' && fs.existsSync(file));
return files;
}

Expand Down
Loading