Exemplo n.º 1
0
        public void GetProjectRootDirectoryWorkingDirectoryWithWorktree()
        {
            RepositoryScope((fixture, vv) =>
            {
                var worktreePath = Path.Combine(Directory.GetParent(fixture.RepositoryPath).FullName, Guid.NewGuid().ToString());
                try
                {
                    // create a branch and a new worktree for it
                    var repo = new Repository(fixture.RepositoryPath);
                    repo.Worktrees.Add("worktree", worktreePath, false);

                    var targetUrl = "https://github.com/GitTools/GitVersion.git";

                    var arguments = new Arguments
                    {
                        TargetUrl  = targetUrl,
                        TargetPath = worktreePath
                    };

                    var gitPreparer = new GitPreparer(log, environment, Options.Create(arguments));

                    gitPreparer.GetProjectRootDirectoryInternal().TrimEnd('/', '\\').ShouldBe(worktreePath);
                }
                finally
                {
                    DirectoryHelper.DeleteDirectory(worktreePath);
                }
            });
        }
Exemplo n.º 2
0
        public void GetProjectRootDirectoryNoWorktree()
        {
            RepositoryScope((fixture, vv) =>
            {
                var targetUrl = "https://github.com/GitTools/GitVersion.git";

                var arguments = new Arguments
                {
                    TargetUrl  = targetUrl,
                    TargetPath = fixture.RepositoryPath
                };

                var gitPreparer  = new GitPreparer(log, environment, Options.Create(arguments));
                var expectedPath = fixture.RepositoryPath.TrimEnd('/', '\\');
                gitPreparer.GetProjectRootDirectoryInternal().TrimEnd('/', '\\').ShouldBe(expectedPath);
            });
        }