From 6288e03264129ff6e57211bf86d7ff7b98d95726 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 25 Jun 2019 09:27:31 +0200 Subject: [PATCH] Wizards: Fix regular expressions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Although this is valid JavaScript matching the '.' is not working as expected. The directory always gets messed up by replacing the first character with a dash. Use an alternate regular expression and also ensure the replacement happens globally instead of once as we want to replace all dots by a dash. As at it fix handling of the file suffixes as well. Task-number: QTCREATORBUG-22625 Change-Id: Ide189fe50e29994abfb368e503050b9b413aba9f Reviewed-by: André Hartmann Reviewed-by: Eike Ziller --- share/qtcreator/templates/wizards/files/java/wizard.json | 2 +- .../templates/wizards/projects/vcs/bazaar/wizard.json | 2 +- .../qtcreator/templates/wizards/projects/vcs/git/wizard.json | 4 ++-- .../templates/wizards/projects/vcs/mercurial/wizard.json | 2 +- .../templates/wizards/projects/vcs/subversion/wizard.json | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/share/qtcreator/templates/wizards/files/java/wizard.json b/share/qtcreator/templates/wizards/files/java/wizard.json index 6341319c6ba..5a8fae5dc16 100644 --- a/share/qtcreator/templates/wizards/files/java/wizard.json +++ b/share/qtcreator/templates/wizards/files/java/wizard.json @@ -9,7 +9,7 @@ "iconText": "java", "enabled": "%{JS: value('Plugins').indexOf('Android') >= 0}", - "options": [ { "key": "ClassName", "value": "%{JS: value('FileName').charAt(0).toUpperCase() + value('FileName').substr(1).replace(/\\.java$/,'')}" } ], + "options": [ { "key": "ClassName", "value": "%{JS: value('FileName').charAt(0).toUpperCase() + value('FileName').substr(1).replace(/[.]java$/,'')}" } ], "pages" : [ diff --git a/share/qtcreator/templates/wizards/projects/vcs/bazaar/wizard.json b/share/qtcreator/templates/wizards/projects/vcs/bazaar/wizard.json index a8b4d041e71..f81509c4ed8 100644 --- a/share/qtcreator/templates/wizards/projects/vcs/bazaar/wizard.json +++ b/share/qtcreator/templates/wizards/projects/vcs/bazaar/wizard.json @@ -14,7 +14,7 @@ { "key": "vcsId", "value": "B.Bazaar" }, { "key": "vcsName", "value": "%{JS: Vcs.displayName('%{vcsId}')}" }, { "key": "SR", "value": "%{JS: '%{Repo}'.substr('%{Repo}'.indexOf(':') + 1) }" }, - { "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/\\./, '-') }"}, + { "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/[.]/g, '-') }"}, { "key": "RevArg", "value": "%{JS: '%{Rev}' !== '' ? '-r' : ''}" }, { "key": "TargetPath", "value": "%{Path}/%{Dir}" } ], diff --git a/share/qtcreator/templates/wizards/projects/vcs/git/wizard.json b/share/qtcreator/templates/wizards/projects/vcs/git/wizard.json index c97698612b6..0295468f6fb 100644 --- a/share/qtcreator/templates/wizards/projects/vcs/git/wizard.json +++ b/share/qtcreator/templates/wizards/projects/vcs/git/wizard.json @@ -13,8 +13,8 @@ [ { "key": "vcsId", "value": "G.Git" }, { "key": "vcsName", "value": "%{JS: Vcs.displayName('%{vcsId}')}" }, - { "key": "SR", "value": "%{JS: '%{Repo}'.replace(/\\.git$/, '') }"}, - { "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/\\./, '-') }"}, + { "key": "SR", "value": "%{JS: '%{Repo}'.replace(/[.]git$/, '') }"}, + { "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/[.]/g, '-') }"}, { "key": "branchArg", "value": "%{JS: '%{Branch}' ? '--branch' : '' }" }, { "key": "TargetPath", "value": "%{Path}/%{Dir}" } ], diff --git a/share/qtcreator/templates/wizards/projects/vcs/mercurial/wizard.json b/share/qtcreator/templates/wizards/projects/vcs/mercurial/wizard.json index 75bd410861a..8e655e1eb66 100644 --- a/share/qtcreator/templates/wizards/projects/vcs/mercurial/wizard.json +++ b/share/qtcreator/templates/wizards/projects/vcs/mercurial/wizard.json @@ -14,7 +14,7 @@ { "key": "vcsId", "value": "H.Mercurial" }, { "key": "vcsName", "value": "%{JS: Vcs.displayName('%{vcsId}')}" }, { "key": "SR", "value": "%{JS: '%{Repo}'.substr('%{Repo}'.indexOf(':') + 1) }"}, - { "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/\\./, '-') }"}, + { "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/[.]/g, '-') }"}, { "key": "TargetPath", "value": "%{Path}/%{Dir}" } ], diff --git a/share/qtcreator/templates/wizards/projects/vcs/subversion/wizard.json b/share/qtcreator/templates/wizards/projects/vcs/subversion/wizard.json index aef8a28b9ac..cfeddbb5327 100644 --- a/share/qtcreator/templates/wizards/projects/vcs/subversion/wizard.json +++ b/share/qtcreator/templates/wizards/projects/vcs/subversion/wizard.json @@ -13,8 +13,8 @@ [ { "key": "vcsId", "value": "J.Subversion" }, { "key": "vcsName", "value": "%{JS: Vcs.displayName('%{vcsId}')}" }, - { "key": "SR", "value": "%{JS: '%{Repo}'.replace(/\\/trunk$/, '').replace(/\\/$/, '') }"}, - { "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/\\./, '-') }"}, + { "key": "SR", "value": "%{JS: '%{Repo}'.replace(/[/]trunk$/, '').replace(/[/]$/, '') }"}, + { "key": "defaultDir", "value": "%{JS: '%{SR}'.substr('%{SR}'.lastIndexOf('/') + 1).replace(/[.]/g, '-') }"}, { "key": "TargetPath", "value": "%{Path}/%{Dir}" } ],