public GitArmorRepositoryConfig LoadOrCreate(string repositoryFolder) { var configFilePath = Path.Combine(repositoryFolder, @".git\gitarmor\config"); if (!m_files.Exists(configFilePath)) { if (!m_dirs.Exists(Path.Combine(repositoryFolder, @".git\gitarmor"))) { m_dirs.CreateDirectory(Path.Combine(repositoryFolder, @".git\gitarmor")); } var jsonConfig = m_serializer.Serialize(new GitArmorRepositoryConfig()); using (var fw = m_files.CreateText(configFilePath)) { fw.WriteLine(jsonConfig); } } string serializedJson = null; using (var fr = m_files.OpenText(configFilePath)) { serializedJson = fr.ReadToEnd(); } return(m_serializer.Deserialize <GitArmorRepositoryConfig>(serializedJson)); }
public void Get_WhenLastIssueFileExists_ShouldReadLastIssueFromIt() { A.CallTo(() => m_file.Exists($@"{m_repositoryDirectory}\.git\gitarmor\issuetracker\lastissue")).Returns(true); var streamReader = A.Fake <TextReader>(); A.CallTo(() => streamReader.ReadLine()).Returns("567"); A.CallTo(() => m_file.OpenText($@"{m_repositoryDirectory}\.git\gitarmor\issuetracker\lastissue")).Returns(streamReader); m_lastIssue.Get().Should().Be("567"); }
public string Get() { if (!m_fileUtilities.Exists(m_lastIssueFile)) { return(string.Empty); } var issue = string.Empty; using (var stream = m_fileUtilities.OpenText(m_lastIssueFile)) { issue = stream.ReadLine(); } return(issue); }