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

Remove duplicate diff column/line reference #51

Merged
merged 1 commit into from
Aug 21, 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
10 changes: 3 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1884,15 +1884,11 @@ function partOfApp(changedFiles, app) {
});
}
function getFirstTwoDirectories(filePath) {
// Normalize the path to handle any inconsistencies
const normalizedPath = path.normalize(filePath);
// Split the path into parts based on the OS-specific separator
const parts = normalizedPath.split(path.sep).filter(Boolean); // filter(Boolean) removes empty strings
// Check if the path has at least two segments
if (parts.length < 2) {
return parts.join(path.sep); // Return the entire path if less than two directories
}
// Join the first two segments
return parts.slice(0, 2).join(path.sep);
}
function asyncForEach(array, callback) {
Expand Down Expand Up @@ -1944,13 +1940,13 @@ function filterDiff(diffText) {
// Split the diff text into sections based on the headers
const sections = diffText.split(/(?=^===== )/m);
const filteredSection = sections.map(section => {
var removedLabels = section.replace(/<\s+argocd\.argoproj\.io\/instance:.*\n---\n>\s+argocd\.argoproj\.io\/instance:.*\n?/g, '').trim();
var removedLabels = removedLabels.replace(/<\s+app.kubernetes.io\/part-of:.*\n?/g, '').trim();
var removedLabels = section.replace(/(\d+(,\d+)?c\d+(,\d+)?\n)?<\s+argocd\.argoproj\.io\/instance:.*\n---\n>\s+argocd\.argoproj\.io\/instance:.*\n?/g, '').trim();
removedLabels = removedLabels.replace(/(\d+(,\d+)?c\d+(,\d+)?\n)?<\s+app.kubernetes.io\/part-of:.*\n?/g, '').trim();
return removedLabels;
}).filter(section => section.trim() !== '');
const removeEmptyHeaders = filteredSection.filter(entry => {
// Remove empty strings and sections that are just headers with line numbers
return !entry.match(/^===== .*\/.* ======\n\d+(,\d+)?c\d+(,\d+)?$/);
return !entry.match(/^===== .*\/.* ======$/);
});
// Join the filtered sections back together
return removeEmptyHeaders.join('\n').trim();
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,14 @@ function filterDiff(diffText: string) {
const sections = diffText.split(/(?=^===== )/m);

const filteredSection = sections.map(section => {
var removedLabels = section.replace(/<\s+argocd\.argoproj\.io\/instance:.*\n---\n>\s+argocd\.argoproj\.io\/instance:.*\n?/g, '').trim();
var removedLabels = removedLabels.replace(/<\s+app.kubernetes.io\/part-of:.*\n?/g, '').trim();
var removedLabels = section.replace(/(\d+(,\d+)?c\d+(,\d+)?\n)?<\s+argocd\.argoproj\.io\/instance:.*\n---\n>\s+argocd\.argoproj\.io\/instance:.*\n?/g, '').trim();
removedLabels = removedLabels.replace(/(\d+(,\d+)?c\d+(,\d+)?\n)?<\s+app.kubernetes.io\/part-of:.*\n?/g, '').trim();
return removedLabels;
}).filter(section => section.trim() !== '');

const removeEmptyHeaders = filteredSection.filter(entry => {
// Remove empty strings and sections that are just headers with line numbers
return !entry.match(/^===== .*\/.* ======\n\d+(,\d+)?c\d+(,\d+)?$/);
return !entry.match(/^===== .*\/.* ======$/);
});

// Join the filtered sections back together
Expand Down
Loading