public VersionConfigurationApplicator(Versions versions, VersionConfiguration configuration)
        {
            Contract.Requires(versions != null);
            Contract.Requires(configuration != null);

            _versions      = versions;
            _configuration = configuration;
        }
示例#2
0
        public static String GenerateFileContents(VersionConfiguration configuration, LibGit2Sharp.IRepository repository)
        {
            Contract.Requires(configuration != null);
            Contract.Ensures(Contract.Result <String>() != null);

            var commits  = GetHeadCommitsFromRepository(repository);
            var tags     = GetTagsFromRepository(repository);
            var versions = VersionFinder.GetVersions(commits, tags);
            var versionConfigurationApplicator = new VersionConfigurationApplicator(versions, configuration);

            return(VersionFileGenerator.GenerateFileContents(versionConfigurationApplicator.Version, versionConfigurationApplicator.FileVersion, versionConfigurationApplicator.InfoVersion));
        }
示例#3
0
        public override Boolean Execute()
        {
            Contract.Assume(Log != null);

            var repositorySearchPathStart = Path.GetDirectoryName(OutputFilePath);
            var repositoryPath            = LibGit2Sharp.Repository.Discover(repositorySearchPathStart);
            var repository = (repositoryPath != null)
                                ? new LibGit2Sharp.Repository(repositoryPath)
                                : null;

            using (repository)
            {
                var configuration = new VersionConfiguration(IncludeAssemblyVersion, IncludeAssemblyFileVersion, IncludeAssemblyInformationalVersion, !OnlyMajorAndMinorInAssemblyVersion, !OnlyMajorAndMinorInAssemblyFileVersion, !OnlyMajorAndMinorInAssemblyInformationalVersion);
                var fileContents  = GitVersion.GenerateFileContents(configuration, repository);
                File.WriteAllText(OutputFilePath, fileContents);
            }

            return(true);
        }