Ejemplo n.º 1
0
        public static Config Provide(string gitDirectory, IFileSystem fileSystem)
        {
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }

            var configFilePath = GetConfigFilePath(gitDirectory);

            if (fileSystem.Exists(configFilePath))
            {
                var readAllText = fileSystem.ReadAllText(configFilePath);

                return(ConfigSerializer.Read(new StringReader(readAllText)));
            }

            return(new Config());
        }
        public static void WriteSample(string targetDirectory, IFileSystem fileSystem)
        {
            if (fileSystem == null)
            {
                throw new ArgumentNullException(nameof(fileSystem));
            }

            var configFilePath = GetConfigFilePath(targetDirectory);

            if (!fileSystem.Exists(configFilePath))
            {
                using (var stream = fileSystem.OpenWrite(configFilePath))
                    using (var writer = new StreamWriter(stream))
                    {
                        ConfigSerializer.WriteSample(writer);
                    }
            }
            else
            {
                Logger.WriteError("Cannot write sample, GitReleaseManager.yaml already exists");
            }
        }