public SemanticVersion FindVersion(IRepository repository, Commit tip)
        {
            int major;
            int minor;
            int patch;
            foreach (var tag in repository.TagsByDate(tip))
            {
                if (ShortVersionParser.TryParse(tag.Name, out major, out minor, out patch))
                {
                    return BuildVersion(repository, tip, major, minor, patch);
                }
            }

            var semanticVersion = new SemanticVersion();

            string versionString;
            if (MergeMessageParser.TryParse(tip, out versionString))
            {
                if (ShortVersionParser.TryParse(versionString, out major, out minor, out patch))
                {
                    semanticVersion = BuildVersion(repository, tip, major, minor, patch);
                }
            }

            semanticVersion.OverrideVersionManuallyIfNeeded(repository);

            if (semanticVersion == null || semanticVersion.IsEmpty())
            {
                throw new WarningException("The head of a support branch should always be a merge commit if you follow gitflow. Please create one or work around this by tagging the commit with SemVer compatible Id.");
            }

            return semanticVersion;
        }
        public SemanticVersion FindVersion(IRepository repository, Commit tip)
        {
            int major;
            int minor;
            int patch;

            foreach (var tag in repository.TagsByDate(tip))
            {
                if (ShortVersionParser.TryParse(tag.Name, out major, out minor, out patch))
                {
                    return(BuildVersion(repository, tip, major, minor, patch));
                }
            }

            string versionString;

            if (MergeMessageParser.TryParse(tip, out versionString))
            {
                if (ShortVersionParser.TryParse(versionString, out major, out minor, out patch))
                {
                    return(BuildVersion(repository, tip, major, minor, patch));
                }
            }

            throw new WarningException("The head of master should always be a merge commit if you follow gitflow. Please create one or work around this by tagging the commit with SemVer compatible Id.");
        }
        SemanticVersion RetrieveMostRecentOptionalTagVersion(
            IRepository repository, SemanticVersion branchVersion, IEnumerable <Commit> take)
        {
            foreach (var commit in take)
            {
                foreach (var tag in repository.TagsByDate(commit))
                {
                    SemanticVersion version;
                    if (!SemanticVersion.TryParse(tag.Name, out version))
                    {
                        continue;
                    }

                    if (branchVersion.Major != version.Major ||
                        branchVersion.Minor != version.Minor ||
                        branchVersion.Patch != version.Patch)
                    {
                        continue;
                    }

                    return(version);
                }
            }

            return(null);
        }
        public SemanticVersion FindVersion(IRepository repository, Commit tip)
        {
            int major;
            int minor;
            int patch;

            foreach (var tag in repository.TagsByDate(tip))
            {
                if (ShortVersionParser.TryParse(tag.Name, out major, out minor, out patch))
                {
                    return(BuildVersion(repository, tip, major, minor, patch));
                }
            }

            var semanticVersion = new SemanticVersion();

            string versionString;

            if (MergeMessageParser.TryParse(tip, out versionString))
            {
                if (ShortVersionParser.TryParse(versionString, out major, out minor, out patch))
                {
                    semanticVersion = BuildVersion(repository, tip, major, minor, patch);
                }
            }

            semanticVersion.OverrideVersionManuallyIfNeeded(repository);

            if (semanticVersion == null || semanticVersion.IsEmpty())
            {
                throw new WarningException("The head of a support branch should always be a merge commit if you follow gitflow. Please create one or work around this by tagging the commit with SemVer compatible Id.");
            }

            return(semanticVersion);
        }
Beispiel #5
0
        public static SemanticVersion NewestSemVerTag(this IRepository repository, Commit commit)
        {
            foreach (var tag in repository.TagsByDate(commit))
            {
                SemanticVersion version;
                if (SemanticVersion.TryParse(tag.Name, out version))
                {
                    return(version);
                }
            }

            return(null);
        }
Beispiel #6
0
        public SemanticVersion FindVersion(IRepository repository, Commit tip)
        {
            foreach (var tag in repository.TagsByDate(tip))
            {
                ShortVersion shortVersion;
                if (ShortVersionParser.TryParse(tag.Name, out shortVersion))
                {
                    return(BuildVersion(tip, shortVersion));
                }
            }

            ShortVersion versionFromTip;

            if (MergeMessageParser.TryParse(tip, out versionFromTip))
            {
                return(BuildVersion(tip, versionFromTip));
            }
            throw new WarningException("The head of master should always be a merge commit if you follow gitflow. Please create one or work around this by tagging the commit with SemVer compatible Id.");
        }
        public SemanticVersion FindVersion(IRepository repository, Commit tip, Config configuration)
        {
            foreach (var tag in repository.TagsByDate(tip))
            {
                SemanticVersion shortVersion;
                if (SemanticVersion.TryParse(tag.Name, configuration.TagPrefix, out shortVersion))
                {
                    return(BuildVersion(tip, shortVersion));
                }
            }

            SemanticVersion versionFromTip;

            if (MergeMessageParser.TryParse(tip, configuration, out versionFromTip))
            {
                var semanticVersion = BuildVersion(tip, versionFromTip);
                semanticVersion.OverrideVersionManuallyIfNeeded(repository, configuration);
                return(semanticVersion);
            }
            throw new WarningException("The head of a support branch should always be a merge commit if you follow gitflow. Please create one or work around this by tagging the commit with SemVer compatible Id.");
        }
        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);
        }
        public SemanticVersion FindVersion(IRepository repository, Commit tip)
        {
            int major;
            int minor;
            int patch;
            foreach (var tag in repository.TagsByDate(tip))
            {
                if (ShortVersionParser.TryParse(tag.Name, out major, out minor, out patch))
                {
                    return BuildVersion(repository, tip, major, minor, patch);
                }
            }

            string versionString;
            if (MergeMessageParser.TryParse(tip, out versionString))
            {
                if (ShortVersionParser.TryParse(versionString, out major, out minor, out patch))
                {
                    return BuildVersion(repository, tip, major, minor, patch);
                }
            }

            throw new ErrorException("The head of a support branch should always be a merge commit if you follow gitflow. Please create one or work around this by tagging the commit with SemVer compatible Id.");
        }
        SemanticVersion RetrieveMostRecentOptionalTagVersion(
            IRepository repository, SemanticVersion branchVersion, IEnumerable<Commit> take)
        {
            foreach (var commit in take)
            {
                foreach (var tag in repository.TagsByDate(commit))
                {
                    SemanticVersion version;
                    if (!SemanticVersion.TryParse(tag.Name, out version))
                    {
                        continue;
                    }

                    if (branchVersion.Major != version.Major ||
                        branchVersion.Minor != version.Minor ||
                        branchVersion.Patch != version.Patch)
                    {
                        continue;
                    }

                    return version;
                }
            }

            return null;
        }