A game about forced loneliness, made by TACStudios
1using System.Collections;
2
3using Codice.CM.Common;
4
5namespace Unity.PlasticSCM.Editor.Views.CreateWorkspace
6{
7 internal static class ValidRepositoryName
8 {
9 internal static string Get(string repositoryName, IList repositories)
10 {
11 string validRepositoryName = GetValidRepositoryName(repositoryName);
12 string result = validRepositoryName;
13
14 int i = 2;
15
16 while (RepositoryExists(result, repositories))
17 {
18 result = validRepositoryName + "_" + i.ToString();
19 i++;
20 }
21
22 return result;
23 }
24
25 static bool RepositoryExists(string repositoryName, IList repositories)
26 {
27 if (repositories == null)
28 return false;
29
30 foreach (RepositoryInfo repInfo in repositories)
31 {
32 if (repInfo.Name.Equals(repositoryName))
33 return true;
34 }
35
36 return false;
37 }
38
39 static string GetValidRepositoryName(string newRepository)
40 {
41 string result = newRepository.Replace(SUBMODULE_SEPARATOR, '-');
42 result = result.Replace(PIPE_CHARACTER, '-');
43 return result;
44 }
45
46 const char SUBMODULE_SEPARATOR = '/';
47 const char PIPE_CHARACTER = '|';
48 }
49}