Example #1
0
        private void AddFile(string file)
        {
            string filePath = _callDirectory.GetPath().ToString() + "\\" + file;

            if (!File.Exists(filePath))
            {
                Console.WriteLine($"error: {filePath} file path doesn't exist");
                return;
            }

            StatusCommand stageStatus = new StatusCommand(_callDirectory);
            Stage         stage       = stageStatus.GetCurrentStage();

            Blob fileBlob = new Blob(new Path(filePath));

            if (fileBlob.ContainsIn(stage.Untracked))
            {
                Stage newStage = stage.AddToTracked(fileBlob);
                newStage.WriteToIndex(_callDirectory);
                fileBlob.CreateBlobObject(_callDirectory);
            }
            else
            {
                Console.WriteLine($"file \"{filePath}\" is already tracked");
            }
        }
Example #2
0
        public void Execute()
        {
            StatusCommand status = new StatusCommand(_callDirectory);
            Stage         stage  = status.GetCurrentStage();

            FileSystem customFileSystem = new FileSystem(stage.Tracked, _callDirectory);

            CustomFileSystem.Directory directory = customFileSystem.GetContent();

            Path startPath = _callDirectory.GetCommonDirectory();
            Tree tree      = directory.ConvertIntoTree(_callDirectory, startPath);

            tree.CreateTreeObject(_callDirectory);

            string commitMessage = String.Empty;

            if (_command.Properties.Count > 0)
            {
                commitMessage = _command.Properties[0];
            }

            Commit commit = new Commit(tree.Hash, commitMessage, "");
            Hash   hash   = commit.CreateCommitObject(_callDirectory);

            UpdateCommitReference(hash);
        }