コード例 #1
0
        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);
            }
        }
コード例 #2
0
        public CommandParser(CallDirectory callDirectory, string[] input)
        {
            _input         = input;
            _callDirectory = callDirectory;

            _command = Parse();
        }
コード例 #3
0
        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());
            }
        }
コード例 #4
0
        // 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();
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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}");
                }
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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;
            }
        }
コード例 #9
0
 public WorkingDirectory(CallDirectory callDirectory)
 {
     _callDirectory = callDirectory;
     _files         = ExtractFiles(_callDirectory.GetPath());
 }
コード例 #10
0
 public IndexParser(CallDirectory callDirectory)
 {
     _callDirectory = callDirectory;
     _stagedFiles   = ReadIndex();
 }
コード例 #11
0
 public Command(string command, List <string> properties, CallDirectory callDirectory)
 {
     CommandName   = command;
     Properties    = properties;
     CallDirectory = callDirectory;
 }