Skip to content

Commit

Permalink
update dist/index file
Browse files Browse the repository at this point in the history
  • Loading branch information
sharma-shreyas committed Oct 15, 2024
1 parent e618946 commit d0b2a13
Showing 1 changed file with 75 additions and 9 deletions.
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 d0b2a13

Please sign in to comment.