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.");
        }
        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 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);
        }
Esempio n. 4
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.");
        }