Skip to content

Commit

Permalink
Merge pull request #141 from sharma-shreyas/main
Browse files Browse the repository at this point in the history
PES-3558 : fix: update extraction of alias from sql file
  • Loading branch information
sharma-shreyas authored Oct 16, 2024
2 parents 674b442 + d0b2a13 commit 6d1316c
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 18 deletions.
84 changes: 75 additions & 9 deletions adapters/integrations/github-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,24 +683,90 @@ export default class GitHubIntegration extends IntegrationInterface {
filePath,
});

logger.withInfo(
`Successfully fetched file contents. File size: ${fileContents.length} bytes`,
integrationName,
headSHA,
"getAssetName"
);

if (fileContents) {
var matches = regExp.exec(fileContents);
if (matches) {
logger.withInfo(
`Found a match: ${matches[1].trim()}`,
integrationName,
headSHA,
"getAssetName"
);
return matches[1].trim();
logger.withInfo(
"Starting regex matching",
integrationName,
headSHA,
"getAssetName"
);
const startRegex =
/{{\s*config\s*\(/im;
const startMatch = fileContents.match(startRegex);
let configSection = ''
if (startMatch) {
const startIndex = startMatch.index;
const openParensIndex = fileContents.indexOf('(', startIndex) + 1;
let openParensCount = 1;
let endIndex = openParensIndex;

while (openParensCount > 0 && endIndex < fileContents.length) {
const char = fileContents[endIndex];

if (char === '(') {
openParensCount++;
} else if (char === ')') {
openParensCount--;
}
endIndex++;
}

const endMarker = '}}';
const finalEndIndex = fileContents.indexOf(endMarker, endIndex) + endMarker.length;

configSection = fileContents.substring(startIndex, finalEndIndex);
logger.withInfo(
"Extracted config section",
integrationName,
headSHA,
"getAssetName"
);

if (configSection){
logger.withInfo(
"Executing final regex",
integrationName,
headSHA,
"getAssetName"
);

var matches = regExp.exec(configSection);

logger.withInfo(
"Successfully executed regex matching",
integrationName,
headSHA,
"getAssetName"
);

}
if (matches) {
logger.withInfo(
`Found a match: ${matches[1].trim()}`,
integrationName,
headSHA,
"getAssetName"
);

return matches[1].trim();
}
}
}

logger.withInfo(
`Using filename as asset name: ${fileName}`,
integrationName,
headSHA,
"getAssetName"
);

return fileName;
} catch (error) {
logger.withError(
Expand Down
84 changes: 75 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26179,24 +26179,90 @@ class GitHubIntegration extends IntegrationInterface {
filePath,
});

logger_logger.withInfo(
`Successfully fetched file contents. File size: ${fileContents.length} bytes`,
integrationName,
headSHA,
"getAssetName"
);

if (fileContents) {
var matches = regExp.exec(fileContents);
if (matches) {
logger_logger.withInfo(
`Found a match: ${matches[1].trim()}`,
integrationName,
headSHA,
"getAssetName"
);
return matches[1].trim();
logger_logger.withInfo(
"Starting regex matching",
integrationName,
headSHA,
"getAssetName"
);
const startRegex =
/{{\s*config\s*\(/im;
const startMatch = fileContents.match(startRegex);
let configSection = ''
if (startMatch) {
const startIndex = startMatch.index;
const openParensIndex = fileContents.indexOf('(', startIndex) + 1;
let openParensCount = 1;
let endIndex = openParensIndex;

while (openParensCount > 0 && endIndex < fileContents.length) {
const char = fileContents[endIndex];

if (char === '(') {
openParensCount++;
} else if (char === ')') {
openParensCount--;
}
endIndex++;
}

const endMarker = '}}';
const finalEndIndex = fileContents.indexOf(endMarker, endIndex) + endMarker.length;

configSection = fileContents.substring(startIndex, finalEndIndex);
logger_logger.withInfo(
"Extracted config section",
integrationName,
headSHA,
"getAssetName"
);

if (configSection){
logger_logger.withInfo(
"Executing final regex",
integrationName,
headSHA,
"getAssetName"
);

var matches = regExp.exec(configSection);

logger_logger.withInfo(
"Successfully executed regex matching",
integrationName,
headSHA,
"getAssetName"
);

}
if (matches) {
logger_logger.withInfo(
`Found a match: ${matches[1].trim()}`,
integrationName,
headSHA,
"getAssetName"
);

return matches[1].trim();
}
}
}

logger_logger.withInfo(
`Using filename as asset name: ${fileName}`,
integrationName,
headSHA,
"getAssetName"
);

return fileName;
} catch (error) {
logger_logger.withError(
Expand Down

0 comments on commit 6d1316c

Please sign in to comment.