Commit 6f82060b authored by Eelco van der Wel's avatar Eelco van der Wel :speech_balloon:
Browse files

Merge branch 'release-2.1.13' into 'dev'

Release 2.1.13

See merge request !395
parents c7952318 23d10b36
Pipeline #9768 failed with stages
in 6 minutes and 22 seconds
Showing with 18 additions and 0 deletions
+18 -0
......@@ -95,4 +95,17 @@ class GitlabService extends ApiService<GitlabAPI> {
}
return jobs;
}
String stringToGitlabSlug(String s) {
// Copied from gitlab 'sluggify' function
// Source: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/utils.rb#L92
String slug = s.toLowerCase();
slug = slug.replaceAllMapped(RegExp('[^a-z0-9]'), (match) => '-');
slug = slug.replaceAllMapped(RegExp('(\A-+|-+\z)'), (match) => '');
return slug;
}
bool isValidGitlabSlug(String s) {
return (s == stringToGitlabSlug(s));
}
}
......@@ -192,6 +192,11 @@ class ProjectProvider with ChangeNotifier {
if (projectName.isEmpty) {
errorMessage = 'Enter a project name';
notifyListeners();
} else if (!_gitlabService.isValidGitlabSlug(projectName)) {
// TODO have a separate field for gitlab projectname and displayname
errorMessage =
'Your project name should only contain lowercase letters, numbers, or dashes';
notifyListeners();
} else if (!await projectNameExists(projectName)) {
errorMessage = 'Project name already exists';
notifyListeners();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment