Skip to content

Commit

Permalink
added cleanLabels func
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Panayil <[email protected]>
  • Loading branch information
sachin-panayil committed Dec 23, 2024
1 parent f2c2dea commit 7db5db0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
12 changes: 9 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,14 @@ function getPRBody(result) {
</details>
`;
}
function cleanLabels(labels) {
const arrayOfLabels = labels.split(",");
var cleanedLabels = [""];
arrayOfLabels.forEach((element) => {
cleanedLabels.push(element.trim());
});
return cleanedLabels;
}
function run(disableRetry) {
return __awaiter(this, void 0, void 0, function* () {
// load the configuration from file or url, depending on which one is configured
Expand Down Expand Up @@ -714,8 +722,6 @@ function run(disableRetry) {
core.startGroup('Sending a PR');
try {
const [owner, repo] = REPO.split('/');
const originalLables = LABELS.replace(/\s/g, "");
const cleanedLabels = originalLables.split(",");
const jsonOutput = repolinter_1.jsonFormatter.formatOutput(result, true);
const files = getFileChanges_1.getFileChanges(jsonOutput);
if (Object.keys(files).length !== 0) {
Expand All @@ -726,7 +732,7 @@ function run(disableRetry) {
body: getPRBody(result),
base: BASE_BRANCH,
head: `repolinter-results-#${RUN_NUMBER}`,
labels: cleanedLabels,
labels: cleanLabels(LABELS),
changes: [{
files,
commit: `changes based on repolinter output`
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ function getPRBody(result: LintResult): string {
`
}

function cleanLabels(labels: string): string[] {
const arrayOfLabels = labels.split(",")
var cleanedLabels = [""]

arrayOfLabels.forEach((element) => {
cleanedLabels.push(element.trim())
})

return cleanedLabels
}

export default async function run(disableRetry?: boolean): Promise<void> {
// load the configuration from file or url, depending on which one is configured
try {
Expand Down Expand Up @@ -169,9 +180,6 @@ export default async function run(disableRetry?: boolean): Promise<void> {

try {
const [owner, repo] = REPO.split('/')
const originalLables = LABELS.replace(/\s/g, "");
const cleanedLabels = originalLables.split(",")

const jsonOutput = jsonFormatter.formatOutput(result, true)
const files = getFileChanges(jsonOutput)

Expand All @@ -183,7 +191,7 @@ export default async function run(disableRetry?: boolean): Promise<void> {
body: getPRBody(result),
base: BASE_BRANCH,
head: `repolinter-results-#${RUN_NUMBER}`,
labels: cleanedLabels,
labels: cleanLabels(LABELS),
changes: [{
files,
commit: `changes based on repolinter output`
Expand Down

0 comments on commit 7db5db0

Please sign in to comment.