Ejemplo n.º 1
0
        public static TeamCityRevisionDto GetByDirectory(string directory)
        {
            if (Directory.Exists(directory))
            {
                var file = GetRevisionFile(Directory.GetFiles(directory, "*.*"));
                if (file != null)
                {
                    return(GetDto(file, File.ReadAllText(file)));
                }
            }

            return(TeamCityRevisionDto.Create());
        }
Ejemplo n.º 2
0
        private static TeamCityRevisionDto GetDto(string filePath, string content)
        {
            var result   = new TeamCityRevisionDto();
            var fileName = Path.GetFileName(filePath);

            if (fileName != null)
            {
                var split = fileName.Split('.');
                result.Build            = Convert.ToInt32(split[0], CultureInfo.InvariantCulture);
                result.Revision         = content;
                result.TeamCityRevision = fileName;
            }

            return(result);
        }
Ejemplo n.º 3
0
        public static TeamCityRevisionDto GetByZipFile(string zipFileName)
        {
            if (File.Exists(zipFileName))
            {
                using (var archive = ZipFile.OpenRead(zipFileName))
                {
                    var file = GetRevisionFile(archive.Entries.Select(e => e.FullName));
                    if (file != null)
                    {
                        var entry = archive.Entries.First(e => e.FullName == file);
                        using var entryStream = entry.Open();
                        using (TextReader reader = new StreamReader(entryStream))
                        {
                            return(GetDto(file, reader.ReadToEnd()));
                        }
                    }
                }
            }

            return(TeamCityRevisionDto.Create());
        }