Ejemplo n.º 1
0
 void EnsureVersionIsValid(ShortVersion version, Branch branch)
 {
     if (version.Patch == 0)
     {
         var message = string.Format("Branch '{0}' doesn't respect the Hotfix branch naming convention. A patch segment different than zero is required.", branch.Name);
         throw new WarningException(message);
     }
 }
 SemanticVersion BuildVersion(Commit tip, ShortVersion shortVersion)
 {
     return(new SemanticVersion
     {
         Major = shortVersion.Major,
         Minor = shortVersion.Minor,
         Patch = shortVersion.Patch,
         BuildMetaData = new SemanticVersionBuildMetaData(null, "support", tip.Sha, tip.When())
     });
 }
Ejemplo n.º 3
0
        public static bool TryParseMajorMinor(string versionString, out ShortVersion shortVersion)
        {
            if (!TryParse(versionString, out shortVersion))
            {
                return(false);
            }

            // Note: during scanning of master we only want the last major / minor, not the patch, so patch must be zero
            return(shortVersion.Patch == 0);
        }
Ejemplo n.º 4
0
        static string GetSemanticVersionPreReleaseTag(GitVersionContext context, ShortVersion shortVersion, int nbHotfixCommits)
        {
            var semanticVersionPreReleaseTag = "beta.1";
            var tagVersion = RecentTagVersionExtractor.RetrieveMostRecentOptionalTagVersion(context.Repository, shortVersion, context.CurrentBranch.Commits.Take(nbHotfixCommits + 1));

            if (tagVersion != null)
            {
                semanticVersionPreReleaseTag = tagVersion;
            }
            return(semanticVersionPreReleaseTag);
        }
Ejemplo n.º 5
0
        public static bool TryParse(Commit mergeCommit, out ShortVersion shortVersion)
        {
            string versionPart;

            if (Inner(mergeCommit, out versionPart))
            {
                return(ShortVersionParser.TryParse(versionPart, out shortVersion));
            }
            shortVersion = null;
            return(false);
        }
Ejemplo n.º 6
0
        public static bool TryParse(string versionString, out ShortVersion shortVersion)
        {
            versionString = versionString.TrimStart('v', 'V');
            int major;
            int minor;
            var patch   = 0;
            var strings = versionString.Split('.');

            if (strings.Length < 2 || strings.Length > 3)
            {
                shortVersion = null;
                return(false);
            }
            if (!int.TryParse(strings[0], out major))
            {
                shortVersion = null;
                return(false);
            }

            if (!int.TryParse(strings[1], out minor))
            {
                shortVersion = null;
                return(false);
            }

            if (strings.Length == 3)
            {
                if (!int.TryParse(strings[2], out patch))
                {
                    shortVersion = null;
                    return(false);
                }
            }

            shortVersion = new ShortVersion {
                Major = major, Minor = minor, Patch = patch
            };
            return(true);
        }
        internal static SemanticVersionPreReleaseTag RetrieveMostRecentOptionalTagVersion(IRepository repository, ShortVersion matchVersion, IEnumerable <Commit> take)
        {
            Commit first = null;

            foreach (var commit in take)
            {
                if (first == null)
                {
                    first = commit;
                }
                foreach (var tag in repository.TagsByDate(commit))
                {
                    SemanticVersion version;
                    if (!SemanticVersion.TryParse(tag.Name, out version))
                    {
                        continue;
                    }

                    if (matchVersion.Major == version.Major &&
                        matchVersion.Minor == version.Minor &&
                        matchVersion.Patch == version.Patch)
                    {
                        var preReleaseTag = version.PreReleaseTag;

                        //If the tag is on the eact commit then dont bump the PreReleaseTag
                        if (first != commit)
                        {
                            preReleaseTag.Number++;
                        }
                        return(preReleaseTag);
                    }
                }
            }

            return(null);
        }