public void CacheKeyForWorktree()
        {
            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));
                    configFileLocator = new DefaultConfigFileLocator(fileSystem, log);
                    var cacheKey      = GitVersionCacheKeyFactory.Create(fileSystem, log, gitPreparer, configFileLocator, null);
                    cacheKey.Value.ShouldNotBeEmpty();
                }
                finally
                {
                    DirectoryHelper.DeleteDirectory(worktreePath);
                }
            });
        }
Beispiel #2
0
        public void CacheKeyForWorktree()
        {
            var versionAndBranchFinder = new ExecuteCore(fileSystem, environment);

            RepositoryScope(versionAndBranchFinder, (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 gitPreparer       = new GitPreparer(targetUrl, null, new Authentication(), false, worktreePath);
                    var configFileLocator = new DefaultConfigFileLocator();
                    var cacheKey          = GitVersionCacheKeyFactory.Create(fileSystem, gitPreparer, null, configFileLocator);
                    cacheKey.Value.ShouldNotBeEmpty();
                }
                finally
                {
                    DirectoryHelper.DeleteDirectory(worktreePath);
                }
            });
        }
Beispiel #3
0
    public void CacheKeySameAfterReNormalizing()
    {
        var versionAndBranchFinder = new ExecuteCore(fileSystem);

        RepositoryScope(versionAndBranchFinder, (fixture, vv) =>
        {
            var targetUrl    = "https://github.com/GitTools/GitVersion.git";
            var targetBranch = "refs/head/master";
            var gitPreparer  = new GitPreparer(targetUrl, null, new Authentication(), false, fixture.RepositoryPath);
            gitPreparer.Initialise(true, targetBranch);
            var cacheKey1 = GitVersionCacheKeyFactory.Create(fileSystem, gitPreparer, null);
            gitPreparer.Initialise(true, targetBranch);
            var cacheKey2 = GitVersionCacheKeyFactory.Create(fileSystem, gitPreparer, null);

            cacheKey2.Value.ShouldBe(cacheKey1.Value);
        });
    }
        public void CacheKeySameAfterReNormalizing()
        {
            RepositoryScope((fixture, vv) =>
            {
                var targetUrl    = "https://github.com/GitTools/GitVersion.git";
                var targetBranch = "refs/head/master";

                var arguments = new Arguments
                {
                    TargetUrl  = targetUrl,
                    TargetPath = fixture.RepositoryPath
                };
                var gitPreparer   = new GitPreparer(log, environment, Options.Create(arguments));
                configFileLocator = new DefaultConfigFileLocator(fileSystem, log);

                gitPreparer.Prepare(true, targetBranch);
                var cacheKey1 = GitVersionCacheKeyFactory.Create(fileSystem, log, gitPreparer, configFileLocator, null);
                gitPreparer.Prepare(true, targetBranch);
                var cacheKey2 = GitVersionCacheKeyFactory.Create(fileSystem, log, gitPreparer, configFileLocator, null);

                cacheKey2.Value.ShouldBe(cacheKey1.Value);
            });
        }