public EffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme,
     VersioningMode versioningMode, string gitTagPrefix,
     string tag, string nextVersion, IncrementStrategy increment,
     string branchPrefixToTrim,
     bool preventIncrementForMergedBranchVersion,
     string tagNumberPattern,
     string continuousDeploymentFallbackTag,
     bool trackMergeTarget,
     string majorVersionBumpMessage,
     string minorVersionBumpMessage,
     string patchVersionBumpMessage,
     CommitMessageIncrementMode commitMessageIncrementing)
 {
     AssemblyVersioningScheme = assemblyVersioningScheme;
     VersioningMode           = versioningMode;
     GitTagPrefix             = gitTagPrefix;
     Tag                = tag;
     NextVersion        = nextVersion;
     Increment          = increment;
     BranchPrefixToTrim = branchPrefixToTrim;
     PreventIncrementForMergedBranchVersion = preventIncrementForMergedBranchVersion;
     TagNumberPattern = tagNumberPattern;
     ContinuousDeploymentFallbackTag = continuousDeploymentFallbackTag;
     TrackMergeTarget          = trackMergeTarget;
     MajorVersionBumpMessage   = majorVersionBumpMessage;
     MinorVersionBumpMessage   = minorVersionBumpMessage;
     PatchVersionBumpMessage   = patchVersionBumpMessage;
     CommitMessageIncrementing = commitMessageIncrementing;
 }
Exemple #2
0
        public void CanInheritVersioningMode(VersioningMode mode)
        {
            var config = new Config
            {
                VersioningMode = mode
            };

            ConfigurationProvider.ApplyDefaultsTo(config);

            var mockBranch = new MockBranch("master")
            {
                new MockCommit {
                    CommitterEx = Generate.SignatureNow()
                }
            };
            var mockRepository = new MockRepository
            {
                Branches = new MockBranchCollection
                {
                    mockBranch
                }
            };

            var context = new GitVersionContext(mockRepository, new NullLog(), mockBranch, config);

            context.Configuration.VersioningMode.ShouldBe(mode);
        }
Exemple #3
0
 public TestEffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme         = AssemblyVersioningScheme.MajorMinorPatch,
     AssemblyFileVersioningScheme assemblyFileVersioningScheme = AssemblyFileVersioningScheme.MajorMinorPatch,
     string assemblyInformationalFormat = null,
     VersioningMode versioningMode      = VersioningMode.ContinuousDelivery,
     string tagPrefix          = "v",
     string tag                = "",
     string nextVersion        = null,
     string branchPrefixToTrim = "",
     bool preventIncrementForMergedBranchVersion = false,
     string tagNumberPattern = null,
     string continuousDeploymentFallbackTag = "ci",
     bool trackMergeTarget = false,
     string majorMessage   = null,
     string minorMessage   = null,
     string patchMessage   = null,
     string noBumpMessage  = null,
     CommitMessageIncrementMode commitMessageMode = CommitMessageIncrementMode.Enabled,
     int buildMetaDataPadding                    = 4,
     int commitsSinceVersionSourcePadding        = 4,
     IEnumerable <IVersionFilter> versionFilters = null,
     bool tracksReleaseBranches                  = false,
     bool isRelease          = false,
     string commitDateFormat = "yyyy-MM-dd",
     int taggedCommitsLimit  = 10) :
     base(assemblyVersioningScheme, assemblyFileVersioningScheme, assemblyInformationalFormat, versioningMode, tagPrefix, tag, nextVersion, IncrementStrategyType.Patch,
          branchPrefixToTrim, preventIncrementForMergedBranchVersion, tagNumberPattern, continuousDeploymentFallbackTag,
          trackMergeTarget,
          majorMessage, minorMessage, patchMessage, noBumpMessage,
          commitMessageMode, buildMetaDataPadding, commitsSinceVersionSourcePadding,
          versionFilters ?? Enumerable.Empty <IVersionFilter>(),
          tracksReleaseBranches, isRelease, commitDateFormat,
          GetDefaultBaseVersionStrategies(), taggedCommitsLimit)
 {
 }
Exemple #4
0
 public EffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme,
     AssemblyFileVersioningScheme assemblyFileVersioningScheme,
     string?assemblyInformationalFormat,
     string?assemblyVersioningFormat,
     string?assemblyFileVersioningFormat,
     VersioningMode versioningMode, string?gitTagPrefix,
     string?tag, string?nextVersion, IncrementStrategy increment,
     string?branchPrefixToTrim,
     bool preventIncrementForMergedBranchVersion,
     string?tagNumberPattern,
     string?continuousDeploymentFallbackTag,
     bool trackMergeTarget,
     string?majorVersionBumpMessage,
     string?minorVersionBumpMessage,
     string?patchVersionBumpMessage,
     string?noBumpMessage,
     CommitMessageIncrementMode commitMessageIncrementing,
     int legacySemVerPaddding,
     int buildMetaDataPadding,
     int commitsSinceVersionSourcePadding,
     IEnumerable <IVersionFilter> versionFilters,
     bool tracksReleaseBranches,
     bool isCurrentBranchRelease,
     string?commitDateFormat,
     bool updateBuildNumber,
     int preReleaseWeight,
     int tagPreReleaseWeight)
 {
     AssemblyVersioningScheme     = assemblyVersioningScheme;
     AssemblyFileVersioningScheme = assemblyFileVersioningScheme;
     AssemblyInformationalFormat  = assemblyInformationalFormat;
     AssemblyVersioningFormat     = assemblyVersioningFormat;
     AssemblyFileVersioningFormat = assemblyFileVersioningFormat;
     VersioningMode     = versioningMode;
     GitTagPrefix       = gitTagPrefix;
     Tag                = tag;
     NextVersion        = nextVersion;
     Increment          = increment;
     BranchPrefixToTrim = branchPrefixToTrim;
     PreventIncrementForMergedBranchVersion = preventIncrementForMergedBranchVersion;
     TagNumberPattern = tagNumberPattern;
     ContinuousDeploymentFallbackTag = continuousDeploymentFallbackTag;
     TrackMergeTarget                 = trackMergeTarget;
     MajorVersionBumpMessage          = majorVersionBumpMessage;
     MinorVersionBumpMessage          = minorVersionBumpMessage;
     PatchVersionBumpMessage          = patchVersionBumpMessage;
     NoBumpMessage                    = noBumpMessage;
     CommitMessageIncrementing        = commitMessageIncrementing;
     LegacySemVerPadding              = legacySemVerPaddding;
     BuildMetaDataPadding             = buildMetaDataPadding;
     CommitsSinceVersionSourcePadding = commitsSinceVersionSourcePadding;
     VersionFilters                   = versionFilters;
     TracksReleaseBranches            = tracksReleaseBranches;
     IsCurrentBranchRelease           = isCurrentBranchRelease;
     CommitDateFormat                 = commitDateFormat;
     UpdateBuildNumber                = updateBuildNumber;
     PreReleaseWeight                 = preReleaseWeight;
     TagPreReleaseWeight              = tagPreReleaseWeight;
 }
Exemple #5
0
        public override bool TestVersioningMode(object container, VersioningMode mode)
        {
            var iPub = container as IPublishable;

            switch (mode)
            {
            case VersioningMode.Public:
                return(iPub.IsPubVersion ?? true);

            case VersioningMode.Current:
                if (VersionManager.Instance.CurrentVersion.ContainsKey(VersionKey))
                {
                    return(iPub.IsPubVersion == null || iPub.IsPubVersion == (bool)VersionManager.Instance.CurrentVersion[VersionKey]);
                }
                break;

            case VersioningMode.Specific:
                if (VersionManager.Instance.SpecificVersion.ContainsKey(VersionKey))
                {
                    return(iPub.IsPubVersion == null || iPub.IsPubVersion == (bool)VersionManager.Instance.SpecificVersion[VersionKey]);
                }
                break;
            }

            return(true);
        }
        public static VersionNumber ComputeNewVersion(bool hasApproving, VersioningMode versioningMode)
        {
            if (!hasApproving)
            {
                switch (versioningMode)
                {
                case VersioningMode.None: return(new VersionNumber(1, 0, VersionStatus.Approved));

                case VersioningMode.Major: return(new VersionNumber(1, 0, VersionStatus.Approved));

                case VersioningMode.Full: return(new VersionNumber(0, 1, VersionStatus.Draft));
                }
            }
            else
            {
                switch (versioningMode)
                {
                case VersioningMode.None: return(new VersionNumber(1, 0, VersionStatus.Pending));

                case VersioningMode.Major: return(new VersionNumber(1, 0, VersionStatus.Pending));

                case VersioningMode.Full: return(new VersionNumber(0, 1, VersionStatus.Draft));
                }
            }
            throw new SnNotSupportedException();
        }
Exemple #7
0
        public void CanInheritVersioningMode(VersioningMode mode)
        {
            using var fixture = new EmptyRepositoryFixture();

            var config = new ConfigurationBuilder()
                         .Add(new Config {
                VersioningMode = mode
            })
                         .Build();

            var branchName = "master";
            var mockBranch = new MockBranch(branchName)
            {
                new MockCommit {
                    CommitterEx = Generate.SignatureNow()
                }
            };
            var mockRepository = new MockRepository
            {
                Head     = mockBranch,
                Branches = new MockBranchCollection
                {
                    mockBranch
                }
            };

            var context = GetGitVersionContext(fixture.RepositoryPath, mockRepository, branchName, config);

            context.Configuration.VersioningMode.ShouldBe(mode);
        }
Exemple #8
0
        public void CanInheritVersioningMode(VersioningMode mode)
        {
            using var fixture = new EmptyRepositoryFixture();

            var config = new ConfigurationBuilder()
                         .Add(new Config {
                VersioningMode = mode
            })
                         .Build();

            const string branchName = "master";

            var mockCommit = GitToolsTestingExtensions.CreateMockCommit();
            var mockBranch = GitToolsTestingExtensions.CreateMockBranch(branchName, mockCommit);

            var branches = Substitute.For <IBranchCollection>();

            branches.GetEnumerator().Returns(_ => ((IEnumerable <IBranch>) new[] { mockBranch }).GetEnumerator());

            var mockRepository = Substitute.For <IGitRepository>();

            mockRepository.Head.Returns(mockBranch);
            mockRepository.Branches.Returns(branches);
            mockRepository.Commits.Returns(mockBranch.Commits);

            var context = GetGitVersionContext(fixture.RepositoryPath, mockRepository, branchName, config);

            context.Configuration.VersioningMode.ShouldBe(mode);
        }
 public TestEffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch, 
     string assemblyInformationalFormat = null,
     VersioningMode versioningMode = VersioningMode.ContinuousDelivery, 
     string gitTagPrefix = "v", 
     string tag = "",
     string nextVersion = null,
     string branchPrefixToTrim = "",
     bool preventIncrementForMergedBranchVersion = false,
     string tagNumberPattern = null,
     string continuousDeploymentFallbackTag = "ci",
     bool trackMergeTarget = false,
     string majorMessage = null,
     string minorMessage = null,
     string patchMessage = null,
     CommitMessageIncrementMode commitMessageMode = CommitMessageIncrementMode.Enabled,
     int legacySemVerPadding = 4,
     int buildMetaDataPadding = 4,
     int commitsSinceVersionSourcePadding = 4) : 
         base(assemblyVersioningScheme, assemblyInformationalFormat, versioningMode, gitTagPrefix, tag, nextVersion, IncrementStrategy.Patch, 
             branchPrefixToTrim, preventIncrementForMergedBranchVersion, tagNumberPattern, continuousDeploymentFallbackTag,
             trackMergeTarget,
             majorMessage, minorMessage, patchMessage,
             commitMessageMode, legacySemVerPadding, buildMetaDataPadding, commitsSinceVersionSourcePadding)
 {
 }
        public void CanInheritVersioningMode(VersioningMode mode)
        {
            var config = new Config
            {
                VersioningMode = mode
            };

            config.Reset();

            var mockBranch = new MockBranch("master")
            {
                new MockCommit {
                    CommitterEx = Generate.SignatureNow()
                }
            };
            var mockRepository = new MockRepository
            {
                Branches = new MockBranchCollection
                {
                    mockBranch
                }
            };

            var context = new GitVersionContext(mockRepository, log, mockBranch, config);

            context.Configuration.VersioningMode.ShouldBe(mode);
        }
Exemple #11
0
        /// <summary>
        /// Utility http webservice to get current versioning mode in case it has been left in an inconsistent state
        /// </summary>
        /// <returns>Data on current and stacked versions</returns>
        public ActionResult Show()
        {
            VersioningMode vm   = VersionManager.Instance.Mode;
            string         mode = "";

            switch (vm)
            {
            case VersioningMode.All:
                mode = "all";
                break;

            case VersioningMode.Current:
                mode = "current";
                break;

            case VersioningMode.Public:
                mode = "public";
                break;

            case VersioningMode.Specific:
                mode = "specific = " + VersionManager.Instance.SpecificVersion.ToString();
                break;
            }

            return(Content(string.Format("Currently: {0}, Stack: {1}", mode, VersionManager.Instance.StackDescribe())));
        }
Exemple #12
0
 public TestEffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch,
     AssemblyInformationalVersioningScheme assemblyInformationalVersioningScheme = AssemblyInformationalVersioningScheme.FullInformationalVersion,
     VersioningMode versioningMode = VersioningMode.ContinuousDelivery,
     string gitTagPrefix           = "v",
     string tag                = "",
     string nextVersion        = null,
     string branchPrefixToTrim = "",
     bool preventIncrementForMergedBranchVersion = false,
     string tagNumberPattern = null,
     string continuousDeploymentFallbackTag = "ci",
     bool trackMergeTarget = false,
     string majorMessage   = null,
     string minorMessage   = null,
     string patchMessage   = null,
     CommitMessageIncrementMode commitMessageMode = CommitMessageIncrementMode.Enabled,
     int legacySemVerPadding  = 4,
     int buildMetaDataPadding = 4) :
     base(assemblyVersioningScheme, assemblyInformationalVersioningScheme, versioningMode, gitTagPrefix, tag, nextVersion, IncrementStrategy.Patch,
          branchPrefixToTrim, preventIncrementForMergedBranchVersion, tagNumberPattern, continuousDeploymentFallbackTag,
          trackMergeTarget,
          majorMessage, minorMessage, patchMessage,
          commitMessageMode, legacySemVerPadding, buildMetaDataPadding)
 {
 }
 public TestEffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme         = AssemblyVersioningScheme.MajorMinorPatch,
     AssemblyFileVersioningScheme assemblyFileVersioningScheme = AssemblyFileVersioningScheme.MajorMinorPatch,
     string?assemblyVersioningFormat     = null,
     string?assemblyFileVersioningFormat = null,
     string?assemblyInformationalFormat  = null,
     VersioningMode versioningMode       = VersioningMode.ContinuousDelivery,
     string gitTagPrefix       = "v",
     string tag                = "",
     string?nextVersion        = null,
     string branchPrefixToTrim = "",
     bool preventIncrementForMergedBranchVersion = false,
     string?tagNumberPattern = null,
     string continuousDeploymentFallbackTag = "ci",
     bool trackMergeTarget = false,
     string?majorMessage   = null,
     string?minorMessage   = null,
     string?patchMessage   = null,
     string?noBumpMessage  = null,
     CommitMessageIncrementMode commitMessageMode = CommitMessageIncrementMode.Enabled,
     int legacySemVerPadding                     = 4,
     int buildMetaDataPadding                    = 4,
     int commitsSinceVersionSourcePadding        = 4,
     IEnumerable <IVersionFilter>?versionFilters = null,
     bool tracksReleaseBranches                  = false,
     bool isRelease          = false,
     string commitDateFormat = "yyyy-MM-dd",
     bool updateBuildNumber  = false) :
     base(assemblyVersioningScheme,
          assemblyFileVersioningScheme,
          assemblyInformationalFormat,
          assemblyVersioningFormat,
          assemblyFileVersioningFormat,
          versioningMode,
          gitTagPrefix,
          tag,
          nextVersion,
          IncrementStrategy.Patch,
          branchPrefixToTrim,
          preventIncrementForMergedBranchVersion,
          tagNumberPattern,
          continuousDeploymentFallbackTag,
          trackMergeTarget,
          majorMessage,
          minorMessage,
          patchMessage,
          noBumpMessage,
          commitMessageMode,
          legacySemVerPadding,
          buildMetaDataPadding,
          commitsSinceVersionSourcePadding,
          versionFilters ?? Enumerable.Empty <IVersionFilter>(),
          tracksReleaseBranches,
          isRelease,
          commitDateFormat,
          updateBuildNumber,
          0,
          0)
 {
 }
Exemple #14
0
        public override bool TestVersioningMode(object container, VersioningMode mode)
        {
            if (!(container is IInternational))
            {
                return(true);
            }

            var iI = container as IInternational;

            switch (mode)
            {
            case VersioningMode.Public:
                return(true);

            case VersioningMode.Current:
                return(true);

            case VersioningMode.Specific:
                if (VersionManager.Instance.SpecificVersion.ContainsKey(VersionKey))
                {
                    return(iI.Locale == (string)VersionManager.Instance.SpecificVersion[VersionKey]);
                }
                break;
            }

            return(true);
        }
 public EffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme,
     VersioningMode versioningMode, string gitTagPrefix,
     string tag, string nextVersion, IncrementStrategy increment,
     string branchPrefixToTrim,
     bool preventIncrementForMergedBranchVersion,
     string tagNumberPattern,
     string continuousDeploymentFallbackTag,
     bool trackMergeTarget,
     string majorVersionBumpMessage,
     string minorVersionBumpMessage,
     string patchVersionBumpMessage,
     CommitMessageIncrementMode commitMessageIncrementing)
 {
     AssemblyVersioningScheme = assemblyVersioningScheme;
     VersioningMode = versioningMode;
     GitTagPrefix = gitTagPrefix;
     Tag = tag;
     NextVersion = nextVersion;
     Increment = increment;
     BranchPrefixToTrim = branchPrefixToTrim;
     PreventIncrementForMergedBranchVersion = preventIncrementForMergedBranchVersion;
     TagNumberPattern = tagNumberPattern;
     ContinuousDeploymentFallbackTag = continuousDeploymentFallbackTag;
     TrackMergeTarget = trackMergeTarget;
     MajorVersionBumpMessage = majorVersionBumpMessage;
     MinorVersionBumpMessage = minorVersionBumpMessage;
     PatchVersionBumpMessage = patchVersionBumpMessage;
     CommitMessageIncrementing = commitMessageIncrementing;
 }
Exemple #16
0
 public static VersioningModeBase GetInstance(this VersioningMode _this)
 {
     return(_this switch
     {
         VersioningMode.ContinuousDelivery => (VersioningModeBase) new ContinuousDeliveryMode(),
         VersioningMode.ContinuousDeployment => new ContinuousDeploymentMode(),
         _ => throw new ArgumentException("No instance exists for this versioning mode.")
     });
Exemple #17
0
 /// <summary>
 /// Push a versioning state with a VersioningMode and a specific ItemVersion (making it active)
 /// </summary>
 /// <param name="mode">The VersioningMode to push</param>
 /// <param name="specificVersion">The SpecificVersion to push</param>
 public void PushState(VersioningMode mode, ItemVersion specificVersion)
 {
     StateStack.Push(new VersioningState {
         Mode = this.Mode, SpecificVersion = this.SpecificVersion
     });
     this.Mode = mode;
     if (specificVersion != null)
     {
         this.SpecificVersion = specificVersion;
     }
 }
 public EffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme,
     AssemblyFileVersioningScheme assemblyFileVersioningScheme,
     string assemblyInformationalFormat,
     VersioningMode versioningMode, string tagPrefix,
     string tag, string nextVersion, IncrementStrategyType increment,
     string branchPrefixToTrim,
     bool preventIncrementForMergedBranchVersion,
     string tagNumberPattern,
     string continuousDeploymentFallbackTag,
     bool trackMergeTarget,
     string majorVersionBumpMessage,
     string minorVersionBumpMessage,
     string patchVersionBumpMessage,
     string noBumpMessage,
     CommitMessageIncrementMode commitMessageIncrementing,
     int buildMetaDataPadding,
     int commitsSinceVersionSourcePadding,
     IEnumerable <IVersionFilter> versionFilters,
     bool tracksReleaseBranches,
     bool isCurrentBranchRelease,
     string commitDateFormat,
     IEnumerable <IBaseVersionStrategy> baseVersionStrategies,
     int taggedCommitsLimit)
 {
     AssemblyVersioningScheme     = assemblyVersioningScheme;
     AssemblyFileVersioningScheme = assemblyFileVersioningScheme;
     AssemblyInformationalFormat  = assemblyInformationalFormat;
     VersioningMode     = versioningMode;
     TagPrefix          = tagPrefix;
     Tag                = tag;
     NextVersion        = nextVersion;
     Increment          = increment;
     BranchPrefixToTrim = branchPrefixToTrim;
     PreventIncrementForMergedBranchVersion = preventIncrementForMergedBranchVersion;
     TagNumberPattern = tagNumberPattern;
     ContinuousDeploymentFallbackTag = continuousDeploymentFallbackTag;
     TrackMergeTarget                 = trackMergeTarget;
     MajorVersionBumpMessage          = majorVersionBumpMessage;
     MinorVersionBumpMessage          = minorVersionBumpMessage;
     PatchVersionBumpMessage          = patchVersionBumpMessage;
     NoBumpMessage                    = noBumpMessage;
     CommitMessageIncrementing        = commitMessageIncrementing;
     BuildMetaDataPadding             = buildMetaDataPadding;
     CommitsSinceVersionSourcePadding = commitsSinceVersionSourcePadding;
     VersionFilters                   = versionFilters;
     TracksReleaseBranches            = tracksReleaseBranches;
     IsCurrentBranchRelease           = isCurrentBranchRelease;
     CommitDateFormat                 = commitDateFormat;
     BaseVersionStrategies            = baseVersionStrategies;
     TaggedCommitsLimit               = taggedCommitsLimit;
 }
Exemple #19
0
        /// <summary>
        /// Push a versioning state with a VersioningMode and a specific ItemVersion (making it active)
        /// </summary>
        /// <param name="mode">The VersioningMode to push</param>
        /// <param name="specificVersion">The SpecificVersion to push</param>
        /// <returns>A versioning context which ensures this pushed changed is removed</returns>
        public VersioningContext PushState(VersioningMode mode, ItemVersion specificVersion)
        {
            StateStack.Push(new VersioningState {
                Mode = this.Mode, SpecificVersion = this.SpecificVersion
            });
            this.Mode = mode;
            if (specificVersion != null)
            {
                this.SpecificVersion = specificVersion;
            }

            return(new VersioningContext(this));
        }
Exemple #20
0
        public static VersioningModeBase GetInstance(this VersioningMode _this)
        {
            switch (_this)
            {
            case VersioningMode.ContinuousDelivery:
                return(new ContinuousDeliveryMode());

            case VersioningMode.ContinuousDeployment:
                return(new ContinuousDeploymentMode());

            default:
                throw new ArgumentException("No instance exists for this versioning mode.");
            }
        }
Exemple #21
0
        public override object CurrentValue(VersioningMode mode, RouteData rd)
        {
            string locale;

            if (rd == null || rd.Values[localeRouteKey] == null)
            {
                locale = defaultLocale;
            }
            else
            {
                var routeLocale = (string)rd.Values[localeRouteKey];
                locale = routeLocaleFromLocale(routeLocale);
            }

            return(locale);
        }
 public static void ApplyBranchDefaults(Config config,
     BranchConfig branchConfig,
     string defaultTag = "useBranchName",
     IncrementStrategy defaultIncrementStrategy = IncrementStrategy.Patch,
     bool defaultPreventIncrement = false,
     VersioningMode? defaultVersioningMode = null, // Looked up from main config
     bool defaultTrackMergeTarget = false,
     string defaultTagNumberPattern = null)
 {
     branchConfig.Tag = branchConfig.Tag ?? defaultTag;
     branchConfig.TagNumberPattern = branchConfig.TagNumberPattern ?? defaultTagNumberPattern;
     branchConfig.Increment = branchConfig.Increment ?? defaultIncrementStrategy;
     branchConfig.PreventIncrementOfMergedBranchVersion = branchConfig.PreventIncrementOfMergedBranchVersion ?? defaultPreventIncrement;
     branchConfig.TrackMergeTarget = branchConfig.TrackMergeTarget ?? defaultTrackMergeTarget;
     branchConfig.VersioningMode = branchConfig.VersioningMode ?? defaultVersioningMode ?? config.VersioningMode;
 }
Exemple #23
0
 public TestEffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch,
     VersioningMode versioningMode = VersioningMode.ContinuousDelivery,
     string gitTagPrefix           = "v",
     string tag                = "",
     string nextVersion        = null,
     string branchPrefixToTrim = "",
     bool preventIncrementForMergedBranchVersion = false,
     string tagNumberPattern = null,
     string continuousDeploymentFallbackTag = "ci",
     bool trackMergeTarget = false) :
     base(assemblyVersioningScheme, versioningMode, gitTagPrefix, tag, nextVersion, IncrementStrategy.Patch,
          branchPrefixToTrim, preventIncrementForMergedBranchVersion, tagNumberPattern, continuousDeploymentFallbackTag,
          trackMergeTarget)
 {
 }
 public TestEffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch,
     VersioningMode versioningMode = VersioningMode.ContinuousDelivery,
     string gitTagPrefix = "v",
     string tag = "",
     string nextVersion = null,
     string branchPrefixToTrim = "",
     bool preventIncrementForMergedBranchVersion = false,
     string tagNumberPattern = null,
     string continuousDeploymentFallbackTag = "ci",
     bool trackMergeTarget = false)
     : base(assemblyVersioningScheme, versioningMode, gitTagPrefix, tag, nextVersion, IncrementStrategy.Patch, 
             branchPrefixToTrim, preventIncrementForMergedBranchVersion, tagNumberPattern, continuousDeploymentFallbackTag,
             trackMergeTarget)
 {
 }
Exemple #25
0
        /// <summary>
        /// Test whether the version of the container fits the VersioningMode given
        /// </summary>
        /// <param name="container">The container whose version is to be tested</param>
        /// <param name="mode">The VersioningMode to test the container against</param>
        /// <returns>True if the version fits the VersioningMode</returns>
        public bool TestVersioningMode(object container, VersioningMode mode)
        {
            if (mode == VersioningMode.All)
            {
                return(true);
            }

            foreach (var versioner in Versioners)
            {
                if (versioner.Versionable(container) && !versioner.TestVersioningMode(container, mode))
                {
                    return(false);
                }
            }

            return(true);
        }
 public EffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme,
     string assemblyInformationalFormat,
     VersioningMode versioningMode, string gitTagPrefix,
     string tag, string nextVersion, IncrementStrategy increment,
     string branchPrefixToTrim,
     bool preventIncrementForMergedBranchVersion,
     string tagNumberPattern,
     string continuousDeploymentFallbackTag,
     bool trackMergeTarget,
     string majorVersionBumpMessage,
     string minorVersionBumpMessage,
     string patchVersionBumpMessage,
     string noBumpMessage,
     CommitMessageIncrementMode commitMessageIncrementing,
     int legacySemVerPaddding,
     int buildMetaDataPadding,
     int commitsSinceVersionSourcePadding,
     IEnumerable<IVersionFilter> versionFilters,
     bool isCurrentBranchDevelop,
     bool isCurrentBranchRelease)
 {
     AssemblyVersioningScheme = assemblyVersioningScheme;
     AssemblyInformationalFormat = assemblyInformationalFormat;
     VersioningMode = versioningMode;
     GitTagPrefix = gitTagPrefix;
     Tag = tag;
     NextVersion = nextVersion;
     Increment = increment;
     BranchPrefixToTrim = branchPrefixToTrim;
     PreventIncrementForMergedBranchVersion = preventIncrementForMergedBranchVersion;
     TagNumberPattern = tagNumberPattern;
     ContinuousDeploymentFallbackTag = continuousDeploymentFallbackTag;
     TrackMergeTarget = trackMergeTarget;
     MajorVersionBumpMessage = majorVersionBumpMessage;
     MinorVersionBumpMessage = minorVersionBumpMessage;
     PatchVersionBumpMessage = patchVersionBumpMessage;
     NoBumpMessage = noBumpMessage;
     CommitMessageIncrementing = commitMessageIncrementing;
     LegacySemVerPadding = legacySemVerPaddding;
     BuildMetaDataPadding = buildMetaDataPadding;
     CommitsSinceVersionSourcePadding = commitsSinceVersionSourcePadding;
     VersionFilters = versionFilters;
     IsCurrentBranchDevelop = isCurrentBranchDevelop;
     IsCurrentBranchRelease = isCurrentBranchRelease;
 }
Exemple #27
0
        public override object CurrentValue(VersioningMode mode)
        {
            bool isEditor = false;

            try
            {
                isEditor = SecurityManager.Current.CurrentUserInRole("E");
            }
            catch { }

            if (!isEditor || mode == VersioningMode.Public)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #28
0
        public override bool TestVersioningMode(object container, VersioningMode mode)
        {
            switch (mode)
            {
            case VersioningMode.All:
                return(true);

            case VersioningMode.Current:
                return(true);

            case VersioningMode.Public:
                return(true);

            case VersioningMode.Specific:
                return(true);
            }

            return(false);
        }
        public void CanInheritVersioningMode(VersioningMode mode)
        {
            var config = new Config
            {
                VersioningMode = mode
            };

            var mockBranch = new MockBranch("master") { new MockCommit { CommitterEx = SignatureBuilder.SignatureNow() } };
            var mockRepository = new MockRepository
            {
                Branches = new MockBranchCollection
                {
                    mockBranch
                }
            };

            var context = new GitVersionContext(mockRepository, mockBranch, config);
            context.Configuration.VersioningMode.ShouldBe(mode);
        }
Exemple #30
0
        public override void SetCurrentVersion(VersioningMode mode, ItemVersion version)
        {
            bool isEditor = false;

            try
            {
                isEditor = LyniconSecurityManager.Current.CurrentUserInRole("E");
            }
            catch { }

            if (!isEditor || mode == VersioningMode.Public)
            {
                version[VersionKey] = true;
            }
            else
            {
                version[VersionKey] = false;
            }
        }
Exemple #31
0
        public static VersionVariables GetVariablesFor(
            SemanticVersion semanticVersion, AssemblyVersioningScheme assemblyVersioningScheme,
            VersioningMode mode, string continuousDeploymentFallbackTag,
            bool currentCommitIsTagged)
        {
            var bmd = semanticVersion.BuildMetaData;

            if (mode == VersioningMode.ContinuousDeployment && !currentCommitIsTagged)
            {
                semanticVersion = new SemanticVersion(semanticVersion);
                // Continuous Delivery always requires a pre-release tag unless the commit is tagged
                if (!semanticVersion.PreReleaseTag.HasTag())
                {
                    semanticVersion.PreReleaseTag.Name = continuousDeploymentFallbackTag;
                }

                // For continuous deployment the commits since tag gets promoted to the pre-release number
                semanticVersion.PreReleaseTag.Number          = semanticVersion.BuildMetaData.CommitsSinceTag;
                semanticVersion.BuildMetaData.CommitsSinceTag = null;
            }

            var variables = new VersionVariables(
                major: semanticVersion.Major.ToString(),
                minor: semanticVersion.Minor.ToString(),
                patch: semanticVersion.Patch.ToString(),
                preReleaseTag: semanticVersion.PreReleaseTag,
                preReleaseTagWithDash: semanticVersion.PreReleaseTag.HasTag() ? "-" + semanticVersion.PreReleaseTag : null,
                buildMetaData: bmd,
                fullBuildMetaData: bmd.ToString("f"),
                majorMinorPatch: string.Format("{0}.{1}.{2}", semanticVersion.Major, semanticVersion.Minor, semanticVersion.Patch),
                semVer: semanticVersion.ToString(),
                legacySemVer: semanticVersion.ToString("l"),
                legacySemVerPadded: semanticVersion.ToString("lp"),
                assemblySemVer: semanticVersion.GetAssemblyVersion(assemblyVersioningScheme),
                fullSemVer: semanticVersion.ToString("f"),
                informationalVersion: semanticVersion.ToString("i"),
                branchName: bmd.Branch,
                sha: bmd.Sha,
                commitDate: bmd.CommitDate.UtcDateTime.ToString("yyyy-MM-dd"));

            return(variables);
        }
Exemple #32
0
        public override void SetCurrentVersion(VersioningMode mode, ItemVersion version)
        {
            var    rd = RouteX.CurrentRouteData();
            string locale;

            if (rd == null || rd.Values[localeRouteKey] == null)
            {
                locale = defaultLocale;
            }
            else
            {
                var routeLocale = (string)rd.Values[localeRouteKey];
                locale = routeLocaleFromLocale(routeLocale);
            }

            version[VersionKey] = locale;

            Thread.CurrentThread.CurrentCulture   = new CultureInfo(locale);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(locale);
        }
        public static VersionVariables GetVariablesFor(
            SemanticVersion semanticVersion, AssemblyVersioningScheme assemblyVersioningScheme,
            VersioningMode mode, string continuousDeploymentFallbackTag,
            bool currentCommitIsTagged)
        {
            var bmd = semanticVersion.BuildMetaData;
            if (mode == VersioningMode.ContinuousDeployment && !currentCommitIsTagged)
            {
                semanticVersion = new SemanticVersion(semanticVersion);
                // Continuous Deployment always requires a pre-release tag unless the commit is tagged
                if (!semanticVersion.PreReleaseTag.HasTag())
                {
                    semanticVersion.PreReleaseTag.Name = continuousDeploymentFallbackTag;
                }

                // For continuous deployment the commits since tag gets promoted to the pre-release number
                semanticVersion.PreReleaseTag.Number = semanticVersion.BuildMetaData.CommitsSinceTag;
                semanticVersion.BuildMetaData.CommitsSinceTag = null;
            }

            var variables = new VersionVariables(
                major: semanticVersion.Major.ToString(),
                minor: semanticVersion.Minor.ToString(),
                patch: semanticVersion.Patch.ToString(),
                preReleaseTag: semanticVersion.PreReleaseTag,
                preReleaseTagWithDash: semanticVersion.PreReleaseTag.HasTag() ? "-" + semanticVersion.PreReleaseTag : null,
                buildMetaData: bmd,
                fullBuildMetaData: bmd.ToString("f"),
                majorMinorPatch: string.Format("{0}.{1}.{2}", semanticVersion.Major, semanticVersion.Minor, semanticVersion.Patch),
                semVer: semanticVersion.ToString(),
                legacySemVer: semanticVersion.ToString("l"),
                legacySemVerPadded: semanticVersion.ToString("lp"),
                assemblySemVer: semanticVersion.GetAssemblyVersion(assemblyVersioningScheme),
                fullSemVer: semanticVersion.ToString("f"),
                informationalVersion: semanticVersion.ToString("i"),
                branchName: bmd.Branch,
                sha: bmd.Sha,
                commitDate: bmd.CommitDate.UtcDateTime.ToString("yyyy-MM-dd"));

            return variables;
        }
Exemple #34
0
 public EffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme,
     string assemblyInformationalFormat,
     VersioningMode versioningMode, string gitTagPrefix,
     string tag, string nextVersion, IncrementStrategy increment,
     string branchPrefixToTrim,
     bool preventIncrementForMergedBranchVersion,
     string tagNumberPattern,
     string continuousDeploymentFallbackTag,
     bool trackMergeTarget,
     string majorVersionBumpMessage,
     string minorVersionBumpMessage,
     string patchVersionBumpMessage,
     CommitMessageIncrementMode commitMessageIncrementing,
     int legacySemVerPaddding,
     int buildMetaDataPadding,
     int commitsSinceVersionSourcePadding,
     IEnumerable <IVersionFilter> versionFilters
     )
 {
     AssemblyVersioningScheme    = assemblyVersioningScheme;
     AssemblyInformationalFormat = assemblyInformationalFormat;
     VersioningMode     = versioningMode;
     GitTagPrefix       = gitTagPrefix;
     Tag                = tag;
     NextVersion        = nextVersion;
     Increment          = increment;
     BranchPrefixToTrim = branchPrefixToTrim;
     PreventIncrementForMergedBranchVersion = preventIncrementForMergedBranchVersion;
     TagNumberPattern = tagNumberPattern;
     ContinuousDeploymentFallbackTag = continuousDeploymentFallbackTag;
     TrackMergeTarget                 = trackMergeTarget;
     MajorVersionBumpMessage          = majorVersionBumpMessage;
     MinorVersionBumpMessage          = minorVersionBumpMessage;
     PatchVersionBumpMessage          = patchVersionBumpMessage;
     CommitMessageIncrementing        = commitMessageIncrementing;
     LegacySemVerPadding              = legacySemVerPaddding;
     BuildMetaDataPadding             = buildMetaDataPadding;
     CommitsSinceVersionSourcePadding = commitsSinceVersionSourcePadding;
     VersionFilters = versionFilters;
 }
Exemple #35
0
 public EffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme,
     VersioningMode versioningMode, string gitTagPrefix,
     string tag, string nextVersion, IncrementStrategy increment,
     string branchPrefixToTrim,
     bool preventIncrementForMergedBranchVersion,
     string tagNumberPattern,
     string continuousDeploymentFallbackTag,
     bool trackMergeTarget)
 {
     AssemblyVersioningScheme = assemblyVersioningScheme;
     VersioningMode           = versioningMode;
     GitTagPrefix             = gitTagPrefix;
     Tag                = tag;
     NextVersion        = nextVersion;
     Increment          = increment;
     BranchPrefixToTrim = branchPrefixToTrim;
     PreventIncrementForMergedBranchVersion = preventIncrementForMergedBranchVersion;
     TagNumberPattern = tagNumberPattern;
     ContinuousDeploymentFallbackTag = continuousDeploymentFallbackTag;
     TrackMergeTarget = trackMergeTarget;
 }
 public EffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme,
     VersioningMode versioningMode, string gitTagPrefix,
     string tag, string nextVersion, IncrementStrategy increment,
     string branchPrefixToTrim,
     bool preventIncrementForMergedBranchVersion,
     string tagNumberPattern,
     string continuousDeploymentFallbackTag,
     bool trackMergeTarget)
 {
     AssemblyVersioningScheme = assemblyVersioningScheme;
     VersioningMode = versioningMode;
     GitTagPrefix = gitTagPrefix;
     Tag = tag;
     NextVersion = nextVersion;
     Increment = increment;
     BranchPrefixToTrim = branchPrefixToTrim;
     PreventIncrementForMergedBranchVersion = preventIncrementForMergedBranchVersion;
     TagNumberPattern = tagNumberPattern;
     ContinuousDeploymentFallbackTag = continuousDeploymentFallbackTag;
     TrackMergeTarget = trackMergeTarget;
 }
 public EffectiveConfiguration(
     AssemblyVersioningScheme assemblyVersioningScheme,
     string assemblyInformationalFormat,
     VersioningMode versioningMode, string gitTagPrefix,
     string tag, string nextVersion, IncrementStrategy increment,
     string branchPrefixToTrim,
     bool preventIncrementForMergedBranchVersion,
     bool disableMergeMessageStrategy,
     string tagNumberPattern,
     string continuousDeploymentFallbackTag,
     bool trackMergeTarget,
     string majorVersionBumpMessage,
     string minorVersionBumpMessage,
     string patchVersionBumpMessage,
     CommitMessageIncrementMode commitMessageIncrementing,
     int legacySemVerPaddding,
     int buildMetaDataPadding
     )
 {
     AssemblyVersioningScheme = assemblyVersioningScheme;
     AssemblyInformationalFormat = assemblyInformationalFormat;
     VersioningMode = versioningMode;
     GitTagPrefix = gitTagPrefix;
     Tag = tag;
     NextVersion = nextVersion;
     Increment = increment;
     BranchPrefixToTrim = branchPrefixToTrim;
     PreventIncrementForMergedBranchVersion = preventIncrementForMergedBranchVersion;
     DisableMergeMessageStrategy = disableMergeMessageStrategy;
     TagNumberPattern = tagNumberPattern;
     ContinuousDeploymentFallbackTag = continuousDeploymentFallbackTag;
     TrackMergeTarget = trackMergeTarget;
     MajorVersionBumpMessage = majorVersionBumpMessage;
     MinorVersionBumpMessage = minorVersionBumpMessage;
     PatchVersionBumpMessage = patchVersionBumpMessage;
     CommitMessageIncrementing = commitMessageIncrementing;
     LegacySemVerPadding = legacySemVerPaddding;
     BuildMetaDataPadding = buildMetaDataPadding;
 }
        public static void GetVersionParams(MCVersion version, out VersioningMode versioningMode, out string version_uuid)
        {
            version_uuid   = "latest_release";
            versioningMode = VersioningMode.LatestRelease;

            if (version != null)
            {
                if (version.UUID == "latest_beta")
                {
                    versioningMode = VersioningMode.LatestBeta;
                }
                else if (version.UUID == "latest_release")
                {
                    versioningMode = VersioningMode.LatestRelease;
                }
                else
                {
                    versioningMode = VersioningMode.None;
                }

                version_uuid = version.UUID;
            }
        }
 public static void ApplyBranchDefaults(Config config,
     BranchConfig branchConfig,
     string branchRegex,
     string defaultTag = "useBranchName",
     IncrementStrategy? defaultIncrementStrategy = null, // Looked up from main config
     bool defaultPreventIncrement = false,
     VersioningMode? defaultVersioningMode = null, // Looked up from main config
     bool defaultTrackMergeTarget = false,
     string defaultTagNumberPattern = null,
     bool tracksReleaseBranches = false,
     bool isReleaseBranch = false,
     bool isMainline = false)
 {
     branchConfig.Regex = string.IsNullOrEmpty(branchConfig.Regex) ? branchRegex : branchConfig.Regex;
     branchConfig.Tag = branchConfig.Tag ?? defaultTag;
     branchConfig.TagNumberPattern = branchConfig.TagNumberPattern ?? defaultTagNumberPattern;
     branchConfig.Increment = branchConfig.Increment ?? defaultIncrementStrategy ?? config.Increment ?? DefaultIncrementStrategy;
     branchConfig.PreventIncrementOfMergedBranchVersion = branchConfig.PreventIncrementOfMergedBranchVersion ?? defaultPreventIncrement;
     branchConfig.TrackMergeTarget = branchConfig.TrackMergeTarget ?? defaultTrackMergeTarget;
     branchConfig.VersioningMode = branchConfig.VersioningMode ?? defaultVersioningMode ?? config.VersioningMode;
     branchConfig.TracksReleaseBranches = branchConfig.TracksReleaseBranches ?? tracksReleaseBranches;
     branchConfig.IsReleaseBranch = branchConfig.IsReleaseBranch ?? isReleaseBranch;
     branchConfig.IsMainline = branchConfig.IsMainline ?? isMainline;
 }
Exemple #40
0
 /// <summary>
 /// Push a versioning state just including a VersioningMode (making it active)
 /// </summary>
 /// <param name="mode">The VersioningMode to push</param>
 public void PushState(VersioningMode mode)
 {
     PushState(mode, null);
 }
Exemple #41
0
 public static VersionNumber ComputeNewVersion(bool hasApproving, VersioningMode versioningMode)
 {
     if (!hasApproving)
     {
         switch (versioningMode)
         {
             case VersioningMode.None: return new VersionNumber(1, 0, VersionStatus.Approved);
             case VersioningMode.Major: return new VersionNumber(1, 0, VersionStatus.Approved);
             case VersioningMode.Full: return new VersionNumber(0, 1, VersionStatus.Draft);
         }
     }
     else
     {
         switch (versioningMode)
         {
             case VersioningMode.None: return new VersionNumber(1, 0, VersionStatus.Pending);
             case VersioningMode.Major: return new VersionNumber(1, 0, VersionStatus.Pending);
             case VersioningMode.Full: return new VersionNumber(0, 1, VersionStatus.Draft);
         }
     }
     throw new NotImplementedException();
 }
Exemple #42
0
        /// <summary>
        /// Test whether the version of the container fits the VersioningMode given
        /// </summary>
        /// <param name="container">The container whose version is to be tested</param>
        /// <param name="mode">The VersioningMode to test the container against</param>
        /// <returns>True if the version fits the VersioningMode</returns>
        public bool TestVersioningMode(object container, VersioningMode mode)
        {
            if (mode == VersioningMode.All)
                return true;

            foreach (var versioner in Versioners)
                if (versioner.Versionable(container) && !versioner.TestVersioningMode(container, mode))
                    return false;

            return true;
        }
Exemple #43
0
 /// <summary>
 /// Push a versioning state with a VersioningMode and a specific ItemVersion (making it active)
 /// </summary>
 /// <param name="mode">The VersioningMode to push</param>
 /// <param name="specificVersion">The SpecificVersion to push</param>
 public void PushState(VersioningMode mode, ItemVersion specificVersion)
 {
     StateStack.Push(new VersioningState { Mode = this.Mode, SpecificVersion = this.SpecificVersion });
     this.Mode = mode;
     if (specificVersion != null)
         this.SpecificVersion = specificVersion;
 }
Exemple #44
0
 /// <summary>
 /// Push a versioning state just including a VersioningMode (making it active)
 /// </summary>
 /// <param name="mode">The VersioningMode to push</param>
 public void PushState(VersioningMode mode)
 {
     PushState(mode, null);
 }
Exemple #45
0
 /// <summary>
 /// Set the current value for this versioning system using supplied mode on supplied ItemVersion
 /// </summary>
 /// <param name="mode">The mode to use</param>
 /// <param name="version">The ItemVersion on which to add the key/value for this versioning system</param>
 public abstract void SetCurrentVersion(VersioningMode mode, ItemVersion version);
Exemple #46
0
 /// <summary>
 /// Test whether the given container's version in this versioning system is included in the supplied VersioningMode
 /// </summary>
 /// <param name="container">The container from which to get the version</param>
 /// <param name="mode">The VersioningMode for which we should run the test for this versioning system</param>
 /// <returns>Whether in this versioning system the container is part of the VersioningMode</returns>
 public abstract bool TestVersioningMode(object container, VersioningMode mode);