public SliceDirectoryList(string root) { var listMaster = new List <Tuple <string, SemVersion, string> >(); var listCustom = new List <Tuple <string, SemVersion, string> >(); foreach (var dir in new DirectoryInfo(root).EnumerateDirectories()) { var semName = new SemName(dir.Name); var semVersion = new SemVersion(semName.VersionPart, semName.PreReleasePart); if (semName.NamePart.EndsWith("custom")) { listCustom.Add(new Tuple <string, SemVersion, string>(semName.NamePart.ToLower(), semVersion, dir.FullName)); } else { listMaster.Add(new Tuple <string, SemVersion, string>(semName.NamePart.ToLower(), semVersion, dir.FullName)); } } listMaster.Sort((x, y) => y.Item2.CompareTo(x.Item2)); listCustom.Sort((x, y) => y.Item2.CompareTo(x.Item2)); if (listMaster.Count > 0) { Add(new SliceDirectory(listMaster[0].Item3)); } if (listCustom.Count > 0) { Add(new SliceDirectory(listCustom[0].Item3)); } }
public void FindDependenciesRecursive(LayerList registryLayers) { foreach (var section in _slice.Sections.Where(s => s.SectionType == SliceSection.Type.DEP)) { foreach (var line in section.Lines) { var semName = new SemName(line); var dep = registryLayers.FindLayer(semName.NamePart); if (dep != null) { Dependencies.Add(dep); dep.FindDependenciesRecursive(registryLayers); } } } if (Dependencies.Count == 0) { foreach (var section in _slice.Sections.Where(s => s.SectionType == SliceSection.Type.OS)) { foreach (var line in section.Lines) { var semName = new SemName(line); if (semName.NamePart != Name) { var os = registryLayers.FindLayer(semName.NamePart); if (os != null) { Dependencies.Add(os); } } } } } }
private static void ScanFiles(string dir, IList <Slice> list, string osName) { foreach (var path in Directory.EnumerateFiles(dir)) { var fileName = Path.GetFileName(path); if (fileName == null || fileName.StartsWith(".")) { continue; } var ext = Path.GetExtension(path); if (ext == ".md" || ext == ".txt") { continue; } var fi = new FileInfo(path); var nameParts = fi.Name.Split("_"); // handles names like debian-8.2_jekyll-3.0 and possibly with more underscores fileName = nameParts.Length == 1 ? nameParts[0] : nameParts[nameParts.Length - 1]; var semName = new SemName(fileName); var lines = File.ReadAllLines(path); var slice = new Slice(semName, lines); if (slice.OsList.Contains(osName)) { list.Add(slice); } } }
private string FetchLatestBranchName() { var list = new List <SemVersion>(); var branches = FetchBranches(); foreach (var branch in branches.Where(b => b != "master")) { var semName = new SemName(branch); list.Add(new SemVersion(semName.VersionPart, semName.PreReleasePart)); } list.Sort((x, y) => y.CompareTo(x)); return(list[0].ToString()); }
public Slice(SemName semName, IList<string> lines) { SemName = semName; SemVersion = new SemVersion(semName.VersionPart, semName.PreReleasePart); Sections = new List<SliceSection>(); OsList = new List<string>(); int lineStart = 0; SliceSection section; while ((section = SliceSection.Parse(lines, lineStart)) != null) { lineStart = section.EndLine > lineStart ? section.EndLine : lineStart + 1; Sections.Add(section); } foreach (var s in Sections.Where(s => s.SectionType == SliceSection.Type.OS)) { foreach (var line in s.Lines.Where(l => !l.StartsWith("#"))) { OsList.Add(new SemName(line.Trim()).NamePart.ToLower()); } } }
public Slice(SemName semName, IList <string> lines) { SemName = semName; SemVersion = new SemVersion(semName.VersionPart, semName.PreReleasePart); Sections = new List <SliceSection>(); OsList = new List <string>(); int lineStart = 0; SliceSection section; while ((section = SliceSection.Parse(lines, lineStart)) != null) { lineStart = section.EndLine > lineStart ? section.EndLine : lineStart + 1; Sections.Add(section); } foreach (var s in Sections.Where(s => s.SectionType == SliceSection.Type.OS)) { foreach (var line in s.Lines.Where(l => !l.StartsWith("#"))) { OsList.Add(new SemName(line.Trim()).NamePart.ToLower()); } } }
private static void ScanFiles(string dir, IList<Slice> list, string osName) { foreach (var path in Directory.EnumerateFiles(dir)) { var fileName = Path.GetFileName(path); if (fileName == null || fileName.StartsWith(".")) continue; var ext = Path.GetExtension(path); if (ext == ".md" || ext == ".txt") continue; var fi = new FileInfo(path); var nameParts = fi.Name.Split("_"); // handles names like debian-8.2_jekyll-3.0 and possibly with more underscores fileName = nameParts.Length == 1 ? nameParts[0] : nameParts[nameParts.Length - 1]; var semName = new SemName(fileName); var lines = File.ReadAllLines(path); var slice = new Slice(semName, lines); if (slice.OsList.Contains(osName)) list.Add(slice); } }
private string FetchLatestBranchName() { var list = new List<SemVersion>(); var branches = FetchBranches(); foreach (var branch in branches.Where(b => b != "master")) { var semName = new SemName(branch); list.Add(new SemVersion(semName.VersionPart, semName.PreReleasePart)); } list.Sort((x, y) => y.CompareTo(x)); return list[0].ToString(); }