public void CreateTreeObject(CallDirectory callDirectory) { string content = String.Empty; foreach (Tree subtree in Subtrees) { //tree <hash> <folderName> subtree.CreateTreeObject(callDirectory); content += CreateTreeDataUnit(subtree); } foreach (Blob blob in Blobs) { //blob <hash> <fileName> content += CreateTreeDataUnit(blob); } Hash hash = new Hash(content); Hash = hash.GetContent(); Path objectPath = callDirectory.GetRepositoryFolder(); objectPath = objectPath.ConcatPath("objects"); objectPath = objectPath.ConcatPath(Hash); using (StreamWriter streamWriter = new StreamWriter(objectPath.ToString())) { streamWriter.Write(content); } }
public CommandParser(CallDirectory callDirectory, string[] input) { _input = input; _callDirectory = callDirectory; _command = Parse(); }
public void CreateBlobObject(CallDirectory callDirectory) { string objectPath = callDirectory.GetRepositoryFolder().ToString() + $"\\objects\\{Hash}"; using (StreamWriter streamWriter = new StreamWriter(objectPath)) { StreamReader contentReader = File.OpenText(FilePath.ToString()); streamWriter.Write(contentReader.ReadToEnd()); } }
// vcs <command> <properties> ... static void Main(string[] args) { string[] command = { "add", "Commands\\AddCommand.cs" }; CallDirectory callDirectory = new CallDirectory(); CommandParser commandParser = new CommandParser(callDirectory, args); Executor commandExecutor = new Executor(commandParser); commandExecutor.Run(); }
public Path GetShortPath(CallDirectory callDirectory) { Path unnecessaryPath = callDirectory.GetRepositoryFolder(); unnecessaryPath = unnecessaryPath.GetUpperDirectory(2); // pass .repo and initialized directory string shortPath = _path.Replace(unnecessaryPath.ToString() + "\\", ""); return(new Path(shortPath)); }
public void WriteToIndex(CallDirectory callDirectory) { string indexPath = callDirectory.GetRepositoryFolder().ToString() + "\\index"; using (StreamWriter streamWriter = new StreamWriter(indexPath)) { foreach (Blob tracked in Tracked) { streamWriter.WriteLine($"{tracked.Hash} {tracked.FilePath}"); } } }
public Hash CreateCommitObject(CallDirectory callDirectory) { string content = ParseContent(); Hash hash = new Hash(content); Path commitPath = callDirectory.GetRepositoryFolder().ConcatPath("commits"); commitPath = commitPath.ConcatPath(hash.GetContent()); using (StreamWriter streamWriter = new StreamWriter(commitPath.ToString())) { streamWriter.Write(content); } return(hash); }
public void PrintInformation(CallDirectory callDirectory) { Console.WriteLine("tracked: "); foreach (Blob file in Tracked) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"\t {file.FilePath}"); Console.ForegroundColor = ConsoleColor.Gray; } Console.WriteLine("\nuntracked: "); foreach (Blob file in Untracked) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"\t {file.FilePath}"); Console.ForegroundColor = ConsoleColor.Gray; } }
public WorkingDirectory(CallDirectory callDirectory) { _callDirectory = callDirectory; _files = ExtractFiles(_callDirectory.GetPath()); }
public IndexParser(CallDirectory callDirectory) { _callDirectory = callDirectory; _stagedFiles = ReadIndex(); }
public Command(string command, List <string> properties, CallDirectory callDirectory) { CommandName = command; Properties = properties; CallDirectory = callDirectory; }