Esempio n. 1
0
        public void GitStatusAndObjectAfterGitAdd()
        {
            string existingFilename = "test.cs";

            this.Enlistment.GetVirtualPathTo(existingFilename).ShouldBeAFile(this.fileSystem);

            GitHelpers.CheckGitCommand(
                this.Enlistment.RepoRoot,
                "add " + existingFilename,
                new string[] { });

            // Status should be correct
            GitHelpers.CheckGitCommand(
                this.Enlistment.RepoRoot,
                "status",
                "On branch " + Properties.Settings.Default.Commitish,
                "Changes to be committed:",
                existingFilename);

            // Object file for the test file should have the correct contents
            ProcessResult result = GitProcess.InvokeProcess(
                this.Enlistment.RepoRoot,
                "hash-object " + existingFilename);

            string objectHash = result.Output.Trim();

            result.Errors.ShouldBeEmpty();

            this.Enlistment.GetObjectPathTo(objectHash).ShouldBeAFile(this.fileSystem);

            GitHelpers.CheckGitCommand(
                this.Enlistment.RepoRoot,
                "cat-file -p " + objectHash,
                this.testFileContents);
        }
Esempio n. 2
0
        public void GitStatusAfterRenameFolderIntoRepo()
        {
            string folderName = "GitStatusAfterRenameFolderIntoRepo";

            // Create the test folder in this.Enlistment.EnlistmentRoot as it's outside of src
            // and is cleaned up when the functional tests run
            string folderPath = Path.Combine(this.Enlistment.EnlistmentRoot, folderName);

            this.fileSystem.CreateDirectory(folderPath);

            string fileName = "GitStatusAfterRenameFolderIntoRepo_file.txt";
            string filePath = Path.Combine(folderPath, fileName);

            this.fileSystem.WriteAllText(filePath, this.testFileContents);
            filePath.ShouldBeAFile(this.fileSystem).WithContents(this.testFileContents);

            this.fileSystem.MoveDirectory(folderPath, this.Enlistment.GetVirtualPathTo(folderName));

            GitHelpers.CheckGitCommand(
                this.Enlistment.RepoRoot,
                "status -uall",
                "On branch " + Properties.Settings.Default.Commitish,
                "Untracked files:",
                folderName + "/",
                folderName + "/" + fileName);
        }
 public void GitBranch()
 {
     GitHelpers.CheckGitCommand(
         this.Enlistment.RepoRoot,
         "branch -a",
         "* " + Properties.Settings.Default.Commitish,
         "remotes/origin/" + Properties.Settings.Default.Commitish);
 }
 public void GitStatus()
 {
     GitHelpers.CheckGitCommand(
         this.Enlistment.RepoRoot,
         "status",
         "On branch " + Properties.Settings.Default.Commitish,
         "nothing to commit, working tree clean");
 }
        public void GitAliasNamedAfterKnownCommandAcquiresLock()
        {
            string alias = nameof(this.GitAliasNamedAfterKnownCommandAcquiresLock);

            GitHelpers.AcquireGVFSLock(this.Enlistment, resetTimeout: 3000);
            GitHelpers.CheckGitCommand(this.Enlistment.RepoRoot, "config --local alias." + alias + " status");
            ProcessResult statusWait = GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, alias, cleanErrors: false);

            statusWait.Errors.ShouldContain("Waiting for 'git hash-object --stdin");
        }
Esempio n. 6
0
        private void CurrentBranchShouldEqual(string commitish)
        {
            // Ensure remote branch has been created
            this.GetRefTreeSha("remotes/origin/" + commitish).ShouldNotBeNull();

            // And head has been updated to local branch, which are both updated
            this.GetRefTreeSha("HEAD")
            .ShouldNotBeNull()
            .ShouldEqual(this.GetRefTreeSha(commitish));

            // Ensure no errors are thrown with git log
            GitHelpers.CheckGitCommand(this.fastFetchRepoRoot, "log");
        }
Esempio n. 7
0
        public void GitStatusAfterFileDelete()
        {
            string existingFilename = "test.cs";

            this.Enlistment.GetVirtualPathTo(existingFilename).ShouldBeAFile(this.fileSystem);
            this.fileSystem.DeleteFile(this.Enlistment.GetVirtualPathTo(existingFilename));
            this.Enlistment.GetVirtualPathTo(existingFilename).ShouldNotExistOnDisk(this.fileSystem);

            GitHelpers.CheckGitCommand(
                this.Enlistment.RepoRoot,
                "status",
                "On branch " + Properties.Settings.Default.Commitish,
                "nothing to commit, working tree clean");
        }
Esempio n. 8
0
        public void GitStatusAfterNewFile()
        {
            string filename = "new.cs";

            this.fileSystem.WriteAllText(this.Enlistment.GetVirtualPathTo(filename), this.testFileContents);

            this.Enlistment.GetVirtualPathTo(filename).ShouldBeAFile(this.fileSystem).WithContents(this.testFileContents);

            GitHelpers.CheckGitCommand(
                this.Enlistment.RepoRoot,
                "status",
                "On branch " + Properties.Settings.Default.Commitish,
                "Untracked files:",
                filename);
        }
Esempio n. 9
0
        public void GitStatusAfterFileRename()
        {
            string oldFilename = "New.cs";

            this.Enlistment.GetVirtualPathTo(oldFilename).ShouldBeAFile(this.fileSystem);

            string newFilename = "test.cs";

            this.fileSystem.MoveFile(this.Enlistment.GetVirtualPathTo(oldFilename), this.Enlistment.GetVirtualPathTo(newFilename));

            GitHelpers.CheckGitCommand(
                this.Enlistment.RepoRoot,
                "status",
                "On branch " + Properties.Settings.Default.Commitish,
                "Untracked files:",
                newFilename);
        }
Esempio n. 10
0
        public void CanFetchAndCheckoutCommitIntoEmptyGitRepo()
        {
            // Get the commit sha for the branch the control repo is on
            string commitSha = GitProcess.Invoke(this.fastFetchControlRoot, "log -1 --format=%H").Trim();

            this.RunFastFetch("--checkout -c " + commitSha);

            string headFilePath = Path.Combine(this.fastFetchRepoRoot, TestConstants.DotGit.Head);

            File.ReadAllText(headFilePath).Trim().ShouldEqual(commitSha);

            // Ensure no errors are thrown with git log
            GitHelpers.CheckGitCommand(this.fastFetchRepoRoot, "log");

            this.fastFetchRepoRoot.ShouldBeADirectory(FileSystemRunner.DefaultRunner)
            .WithDeepStructure(this.fastFetchControlRoot);
        }
Esempio n. 11
0
        public void GitStatusAfterUnstage()
        {
            string existingFilename = "test.cs";

            this.Enlistment.GetVirtualPathTo(existingFilename).ShouldBeAFile(this.fileSystem);

            GitHelpers.CheckGitCommand(
                this.Enlistment.RepoRoot,
                "reset HEAD " + existingFilename,
                new string[] { });

            GitHelpers.CheckGitCommand(
                this.Enlistment.RepoRoot,
                "status",
                "On branch " + Properties.Settings.Default.Commitish,
                "Untracked files:",
                existingFilename);
        }
Esempio n. 12
0
        public void GitStatusAfterRenameFileIntoRepo()
        {
            string filename = "GitStatusAfterRenameFileIntoRepo.cs";

            // Create the test file in this.Enlistment.EnlistmentRoot as it's outside of src
            // and is cleaned up when the functional tests run
            string filePath = Path.Combine(this.Enlistment.EnlistmentRoot, filename);

            this.fileSystem.WriteAllText(filePath, this.testFileContents);
            filePath.ShouldBeAFile(this.fileSystem).WithContents(this.testFileContents);

            string renamedFileName = "GVFlt_MoveFileTest\\GitStatusAfterRenameFileIntoRepo.cs";

            this.fileSystem.MoveFile(filePath, this.Enlistment.GetVirtualPathTo(renamedFileName));
            this.Enlistment.GetVirtualPathTo(filePath).ShouldNotExistOnDisk(this.fileSystem);

            GitHelpers.CheckGitCommand(
                this.Enlistment.RepoRoot,
                "status",
                "On branch " + Properties.Settings.Default.Commitish,
                "Untracked files:",
                renamedFileName.Replace('\\', '/'));
        }
 public void GitLog()
 {
     GitHelpers.CheckGitCommand(this.Enlistment.RepoRoot, "log -n1", "commit", "Author:", "Date:");
 }