public void Execute(ICollection <string> args) { if (string.IsNullOrEmpty(repoHelper.Project.Name)) { ch.WriteLine("You need to initialize a repository first.", ConsoleColor.Red); return; } repoHelper.CheckForNewCommitSection(); repoHelper.RemoveRepitionFromNewCommit(); var repoView = repoHelper.GetRepositoryFilesFromXML(); var files = repoHelper.GetFiles(repoHelper.Project.Path); var newCommitFiles = repoHelper.GetNewCommitFiles(); repoHelper.ClearIndexFromRemovedFiles(files.Select(f => f.ShotFileName(repoHelper.Project.Path)), newCommitFiles); foreach (var file in files) { if (repoView.Any(f => f.Name == file.ShotFileName(repoHelper.Project.Path) && f.LAstWriteTime == file.LastWriteTime)) { continue; } if (repoView.Any(f => f.Name == file.ShotFileName(repoHelper.Project.Path) && f.LAstWriteTime != file.LastWriteTime)) { ch.WrtieModified(file.ShotFileName(repoHelper.Project.Path), ConsoleColor.Red); continue; } if (repoView.All(f => f.Name != file.ShotFileName(repoHelper.Project.Path)) && newCommitFiles.All(c => c.Name != file.ShotFileName(repoHelper.Project.Path))) { ch.WrtieAdded(file.ShotFileName(repoHelper.Project.Path), ConsoleColor.Red); continue; } if (newCommitFiles.Any(f => f.Name == file.ShotFileName(repoHelper.Project.Path) && f.LAstWriteTime == file.LastWriteTime)) { var model = newCommitFiles.First(f => f.Name == file.ShotFileName(repoHelper.Project.Path) && f.LAstWriteTime == file.LastWriteTime); ch.WriteLine(string.Format("\t{0}: {1}", model.Status, model.Name), ConsoleColor.Green); continue; } ch.WriteLine(string.Format("\twtf? {0}", file.ShotFileName(repoHelper.Project.Path)), ConsoleColor.DarkCyan); } foreach (var model in repoView) { if (files.All(f => f.ShotFileName(repoHelper.Project.Path) != model.Name) && newCommitFiles.All(c => c.Name != model.Name)) { ch.WrtieRemoved(model.Name, ConsoleColor.Red); } else if (newCommitFiles.Any(c => c.Name == model.Name)) { ch.WrtieRemoved(model.Name, ConsoleColor.Green); } } }
public void Execute(ICollection <string> args) { if (args.Count < 1) { ch.WriteLine("Not enough args ", ConsoleColor.Red); return; } List <FileViewModel> files = null; var commitName = args.ToList()[0]; string parent = string.Empty; string comment = string.Empty; if (args.ToList()[0] == "init") { files = repository.GetiInitFiles().ToList(); comment = "Initial commit"; } else { repository.RemoveRepitionFromNewCommit(); repository.ClearIndexFromRemovedFiles(repository.GetFiles(repository.Project.Path) .Select(f => f.ShotFileName(repository.Project.Path)), repository.GetNewCommitFiles()); files = repository.GetNewCommitFiles().ToList(); comment = args.Count > 1 ? args.ToList()[0] : string.Empty; parent = repository.GetParentCommitId(); } var respseInfo = (ResponseInfo)httpHelper.SendMeta(commitName, parent, storageHelper.UserName, repository.Project.Name, comment); if (respseInfo.StatusCode == HttpStatusCode.OK) { var fileCounter = 0; foreach (var file in files) { var fileResponse = httpHelper.SendFile(file, respseInfo.CommitId); if (fileResponse.StatusCode != HttpStatusCode.OK) { ch.WriteLine(fileResponse.Description, ConsoleColor.Red); continue; } ++fileCounter; } ch.WriteLine(string.Format("{0}/{1} files was added", fileCounter, files.Count)); if (args.ToList()[0] != "init") { repository.UpdateNewCommitSection(commitName, respseInfo.CommitId); } } else { ch.WriteLine(respseInfo.Description, ConsoleColor.Red); } }
private void AddAllFiles() { IEnumerable <FileInfo> files = repositoryhHelper.GetFiles(repositoryhHelper.Project.Path); var counter = 0; foreach (var file in files) { AddFile(file, ref counter); } CheckForRemoval(files, ref counter); repositoryhHelper.ClearIndexFromRemovedFiles(files.Select(f => f.ShotFileName(repositoryhHelper.Project.Path)), repositoryhHelper.GetNewCommitFiles()); if (counter < 1) { ch.WriteLine("Nothing to update"); } }