Beispiel #1
0
        private BaseVersion CreateBaseVersion(GitVersionContext context, VersionTaggedCommit version)
        {
            var shouldUpdateVersion = version.Commit.Sha != context.CurrentCommit.Sha;
            var baseVersion         = new BaseVersion(FormatSource(version), shouldUpdateVersion, version.SemVer, version.Commit, null);

            return(baseVersion);
        }
        bool GetVersion(GitVersionContext context, out VersionTaggedCommit versionTaggedCommit)
        {
            string currentBranchName = null;
            var    head = context.Repository.Head;

            if (head != null)
            {
                currentBranchName = head.CanonicalName;
            }

            var olderThan = context.CurrentCommit.When();
            var allTags   = context.Repository.Tags
                            .Where(tag => ((Commit)tag.PeeledTarget()).When() <= olderThan)
                            .ToList();
            var tagsOnBranch = context.CurrentBranch
                               .Commits
                               .SelectMany(commit =>
            {
                return(allTags.Where(t => IsValidTag(context, currentBranchName, t, commit)));
            })
                               .Select(t =>
            {
                SemanticVersion version;
                if (SemanticVersion.TryParse(t.Name, context.Configuration.GitTagPrefix, out version))
                {
                    return(new VersionTaggedCommit((Commit)t.PeeledTarget(), version, t.Name));
                }
                return(null);
            })
                               .Where(a => a != null)
                               .ToList();

            if (tagsOnBranch.Count == 0)
            {
                versionTaggedCommit = null;
                return(false);
            }
            if (tagsOnBranch.Count == 1)
            {
                versionTaggedCommit = tagsOnBranch[0];
                return(true);
            }

            versionTaggedCommit = tagsOnBranch.Skip(1).Aggregate(tagsOnBranch[0], (t, t1) => t.SemVer > t1.SemVer ? t : t1);
            return(true);
        }
        bool GetVersion(GitVersionContext context, out VersionTaggedCommit versionTaggedCommit)
        {
            string currentBranchName = null;
            var head = context.Repository.Head;
            if (head != null)
            {
                currentBranchName = head.CanonicalName;
            }

            var olderThan = context.CurrentCommit.When();
            var allTags = context.Repository.Tags
                .Where(tag => ((Commit)tag.PeeledTarget()).When() <= olderThan)
                .ToList();
            var tagsOnBranch = context.CurrentBranch
                .Commits
                .SelectMany(commit =>
                {
                    return allTags.Where(t => IsValidTag(context, currentBranchName, t, commit));
                })
                .Select(t =>
                {
                    SemanticVersion version;
                    if (SemanticVersion.TryParse(t.Name, context.Configuration.GitTagPrefix, out version))
                    {
                        return new VersionTaggedCommit((Commit)t.PeeledTarget(), version, t.Name);
                    }
                    return null;
                })
                .Where(a => a != null)
                .ToList();

            if (tagsOnBranch.Count == 0)
            {
                versionTaggedCommit = null;
                return false;
            }
            if (tagsOnBranch.Count == 1)
            {
                versionTaggedCommit = tagsOnBranch[0];
                return true;
            }

            versionTaggedCommit = tagsOnBranch.Skip(1).Aggregate(tagsOnBranch[0], (t, t1) => t.SemVer > t1.SemVer ? t : t1);
            return true;
        }
Beispiel #4
0
 protected virtual string FormatSource(VersionTaggedCommit version)
 {
     return($"Git tag '{version.Tag}'");
 }
 protected virtual string FormatSource(VersionTaggedCommit version)
 {
     return(string.Format("Git tag '{0}'", version.Tag));
 }
 protected override string FormatSource(VersionTaggedCommit version)
 {
     return(string.Format("Merge target tagged '{0}'", version.Tag));
 }
 protected override string FormatSource(VersionTaggedCommit version)
 {
     return string.Format("Merge target tagged '{0}'", version.Tag);
 }
 protected virtual string FormatSource(VersionTaggedCommit version)
 {
     return string.Format("Git tag '{0}'", version.Tag);
 }
 BaseVersion CreateBaseVersion(GitVersionContext context, VersionTaggedCommit version)
 {
     var shouldUpdateVersion = version.Commit.Sha != context.CurrentCommit.Sha;
     var baseVersion = new BaseVersion(FormatSource(version), shouldUpdateVersion, version.SemVer, version.Commit, null);
     return baseVersion;
 }
Beispiel #10
0
 private static string FormatType(VersionTaggedCommit version)
 {
     return($"Hg tag '{version.Tag}'");
 }
Beispiel #11
0
        private static BaseVersion CreateBaseVersion(IVersionContext context, VersionTaggedCommit version)
        {
            var shouldUpdateVersion = version.Commit.Hash != context.CurrentCommit.Hash;

            return(new BaseVersion(FormatType(version), version.SemVer, version.Commit, shouldUpdateVersion));
        }