Ejemplo n.º 1
0
        public static bool SetVersionTag(this ICakeContext context, DirectoryPath repositoryPath, VersionVariables variables)
        {
            #region Arguments check (DupFinder Exclusion)
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (repositoryPath == null)
            {
                throw new ArgumentNullException(nameof(repositoryPath));
            }
            #endregion

            var path = repositoryPath.MakeAbsolute(context.Environment);

            using (context.AddLoggers())
                using (var repository = new Repository(path.FullPath))
                {
                    var version        = SemanticVersion.Parse(variables.FullSemVer);
                    var versionContext = new HgVersionContext((HgRepository)repository);

                    if (versionContext.IsCurrentCommitTagged && version <= versionContext.CurrentCommitTaggedVersion)
                    {
                        return(false);
                    }

                    var commit  = versionContext.CurrentCommit.Hash;
                    var command = new TagCommand()
                                  .WithName(variables.SemVer)
                                  .WithRevision(commit);

                    repository.Tag(command);
                    return(true);
                }
        }
Ejemplo n.º 2
0
        public static void UpdateAssemblyInfo(this ICakeContext context, VersionVariables variables, DirectoryPath workingDirectory, string assemblyInfoFile = "SolutionInfo.cs")
        {
            #region Arguments check (DupFinder Exclusion)
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (variables == null)
            {
                throw new ArgumentNullException(nameof(variables));
            }
            if (workingDirectory == null)
            {
                throw new ArgumentNullException(nameof(workingDirectory));
            }
            if (assemblyInfoFile == null)
            {
                throw new ArgumentNullException(nameof(assemblyInfoFile));
            }
            #endregion

            var fileSystem = new VCSVersion.Helpers.FileSystem();

            using (context.AddLoggers())
                using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDirectory.FullPath, variables, fileSystem, true))
                {
                    assemblyInfoFileUpdater.Update();
                    assemblyInfoFileUpdater.CommitChanges();
                }
        }
Ejemplo n.º 3
0
        public static VersionVariables GetVersion(this ICakeContext context, DirectoryPath repositoryPath)
        {
            #region Arguments check (DupFinder Exclusion)
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (repositoryPath == null)
            {
                throw new ArgumentNullException(nameof(repositoryPath));
            }
            #endregion

            var path = repositoryPath.MakeAbsolute(context.Environment);

            using (context.AddLoggers())
                using (var repository = new Repository(path.FullPath))
                {
                    var versionContext = new HgVersionContext((HgRepository)repository);

                    var finder    = new VersionFinder();
                    var version   = finder.FindVersion(versionContext);
                    var variables = version.ToVersionVariables(versionContext);

                    return(variables);
                }
        }
Ejemplo n.º 4
0
        public static void UpdateAssemblyInfo(this ICakeContext context, VersionVariables variables, DirectoryPath workingDirectory)
        {
            var assemblyInfoFile = "SolutionInfo.cs";
            var fileSystem       = new VCSVersion.Helpers.FileSystem();

            using (context.AddLoggers())
                using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDirectory.FullPath, variables, fileSystem, true))
                {
                    assemblyInfoFileUpdater.Update();
                    assemblyInfoFileUpdater.CommitChanges();
                }
        }