예제 #1
0
        public TagInfo Increment(SemVerElement element)
        {
            var nextVersion = Increment(LatestTag, element);
            var newTag      = _repo.Git.ApplyTag($"{Name}_{nextVersion}", Tip.Sha);
            var newTagInfo  = TagInfo.ParseOrDefault(newTag);

            _tags.Insert(0, newTagInfo);
            return(newTagInfo);
        }
예제 #2
0
        public void increment(
            [Operand(Name = "project", Description = "The id or name of the project")] string projectKey,
            [Option(ShortName = "t")] SemVerElement type = SemVerElement.patch)
        {
            var project = _repo.GetProjectOrDefault(projectKey) ?? throw new ArgumentException($"unknown project:{projectKey}");
            var nextTag = project.Increment(type);

            _writeln($"added {nextTag.FriendlyName}");
            _writeln("run the following command to push the tag to the remote");
            _writeln(null);
            _writeln($"git push origin {nextTag.FriendlyName}".Theme_GitLinks());
        }
예제 #3
0
        private SemVersion Increment(TagInfo tagInfo, SemVerElement type)
        {
            var semver = tagInfo?.SemVersion ?? new SemVersion(0, 0, 0);

            switch (type)
            {
            case SemVerElement.major:
                return(semver.Change(major: semver.Major + 1, minor: 0, patch: 0, prerelease: null));

            case SemVerElement.minor:
                return(semver.Change(minor: semver.Minor + 1, patch: 0, prerelease: null));

            case SemVerElement.patch:
                return(semver.Change(patch: semver.Patch + 1, prerelease: null));

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }