From 398b67fb8ba0dc5c889f3568c04971380f370f1d Mon Sep 17 00:00:00 2001 From: Rhys Koedijk Date: Fri, 11 Oct 2024 12:38:34 +1300 Subject: [PATCH] Clean up --- .../utils/dependabot-cli/DependabotOutputProcessor.ts | 4 +--- .../tasks/dependabotV2/utils/dependabot-cli/getBranchName.ts | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/extension/tasks/dependabotV2/utils/dependabot-cli/DependabotOutputProcessor.ts b/extension/tasks/dependabotV2/utils/dependabot-cli/DependabotOutputProcessor.ts index 29e4ca75..1f0da132 100644 --- a/extension/tasks/dependabotV2/utils/dependabot-cli/DependabotOutputProcessor.ts +++ b/extension/tasks/dependabotV2/utils/dependabot-cli/DependabotOutputProcessor.ts @@ -98,15 +98,13 @@ export class DependabotOutputProcessor implements IDependabotUpdateOutputProcess // Create a new pull request const changedFiles = getPullRequestChangedFilesForOutputData(data); - const directory = - update.config.directory || update.config.directories?.find((dir) => changedFiles[0]?.path?.startsWith(dir)); const dependencies = getPullRequestDependenciesPropertyValueForOutputData(data); const targetBranch = update.config['target-branch'] || (await this.prAuthorClient.getDefaultBranch(project, repository)); const sourceBranch = getBranchNameForUpdate( update.config['package-ecosystem'], targetBranch, - directory, + update.config.directory || update.config.directories?.find((dir) => changedFiles[0]?.path?.startsWith(dir)), dependencies['dependency-group-name'], dependencies['dependencies'] || dependencies, update.config['pull-request-branch-name']?.separator, diff --git a/extension/tasks/dependabotV2/utils/dependabot-cli/getBranchName.ts b/extension/tasks/dependabotV2/utils/dependabot-cli/getBranchName.ts index 3abf085d..f025b4ad 100644 --- a/extension/tasks/dependabotV2/utils/dependabot-cli/getBranchName.ts +++ b/extension/tasks/dependabotV2/utils/dependabot-cli/getBranchName.ts @@ -54,6 +54,7 @@ function sanitizeRef(refParts: string[], separator): string { .replace(/[^A-Za-z0-9\/\-_.(){}]/g, '') // Slashes can't be followed by periods .replace(/\/\./g, '/dot-') + // Squeeze out consecutive periods and slashes .replace(/\.+/g, '.') .replace(/\/+/g, '/') // Trailing periods are forbidden