public void IfPathIsNotAGitRepo_MustReturnAnEmptyString() {
            DirectoryInfo folder = Directory.CreateDirectory(Path.Combine(baseTestPath, "Test1"));

            var branchGetter = new BranchGetter();
            string branchName = branchGetter.GetCurrentBranchName(folder.FullName);

            Assert.AreEqual(string.Empty, branchName);
        }
        private void UpdateBranchName() {
            var fileName = dte.Solution.FileName;
            if (string.IsNullOrWhiteSpace(fileName)) return;

            var branchGetter = new BranchGetter();
            var branchName = branchGetter.GetCurrentBranchName(new FileInfo(fileName).DirectoryName);

            ChangeWindowTitle(branchName);
        }
        public void IfGitFolderDoesNotHaveAHeadFile_MustReturnAnEmptyString() {
            DirectoryInfo gitFolder = Directory.CreateDirectory(Path.Combine(baseTestPath, "Test2", ".git"));

            var branchGetter = new BranchGetter();
            string branchName = branchGetter.GetCurrentBranchName(gitFolder.FullName);

            Assert.AreEqual(string.Empty, branchName);

        }
        public void IfCurrentBranchBelongsToATree_MustReturnTheFullNameOfTheCurrentBranch() {
            DirectoryInfo path = Directory.CreateDirectory(Path.Combine(baseTestPath, "Test4"));
            DirectoryInfo gitFolder = Directory.CreateDirectory(Path.Combine(path.FullName, ".git"));
            using (StreamWriter file = new StreamWriter(Path.Combine(gitFolder.FullName, "HEAD"), false)) {
                file.WriteLine("ref: refs/heads/feature/develop123");
            }

            var branchGetter = new BranchGetter();
            string branchName = branchGetter.GetCurrentBranchName(path.FullName);

            Assert.AreEqual("feature/develop123", branchName);
        }
        private void UpdateBranchName()
        {
            var fileName = dte.Solution.FileName;

            if (string.IsNullOrWhiteSpace(fileName))
            {
                return;
            }

            var branchGetter = new BranchGetter();
            var branchName   = branchGetter.GetCurrentBranchName(new FileInfo(fileName).DirectoryName);

            ChangeWindowTitle(branchName);
        }
        public void IfTheGitReferencesFolderIsInAParentDirectory_MustReturnTheFullNameOfTheCurrentBranch() {
            DirectoryInfo path = Directory.CreateDirectory(Path.Combine(baseTestPath, "Test5"));
            DirectoryInfo gitFolder = Directory.CreateDirectory(Path.Combine(path.FullName, ".git"));
            using (StreamWriter file = new StreamWriter(Path.Combine(gitFolder.FullName, "HEAD"), false)) {
                file.WriteLine("ref: refs/heads/feature/develop123");
            }

            DirectoryInfo subFolder = Directory.CreateDirectory(Path.Combine(baseTestPath, "Test5", "Sub1", "Sub2"));

            var branchGetter = new BranchGetter();
            string branchName = branchGetter.GetCurrentBranchName(subFolder.FullName);

            Assert.AreEqual("feature/develop123", branchName);
        }
        public void IfPathIsInvalid_MustReturnAnEmptyString(string path) {
            var branchGetter = new BranchGetter();
            string branchName = branchGetter.GetCurrentBranchName(path);

            Assert.AreEqual(string.Empty, branchName);
        }