public BasicCommitInfo GetInfo(Commit c) { string sha = c.Sha; if (_cache.TryGetValue(sha, out var d)) { return(d); } TagCommit commit = _collector.GetCommit(sha); ITagCommit best; if (commit != null) { best = commit.GetBestCommitExcept(_excluded); } else { TagCommit content = _collector.GetCommit(c.Tree.Sha); best = content?.GetBestCommitExcept(_excluded); } BasicCommitInfo p = ReadParents(c); if (best != null || p != null) { d = new BasicCommitInfo(commit, best, p); } _cache.Add(sha, d); return(d); }
void RegisterOneTag(StringBuilder errors, Commit c, string tagName, int?singleMajor, ref bool startingVersionForCSemVerFound) { CSVersion v = CSVersion.TryParse(tagName); if (v.IsValid && (!singleMajor.HasValue || v.Major == singleMajor.Value)) { if (_startingVersionForCSemVer != null) { int cmp = _startingVersionForCSemVer.CompareTo(v); if (cmp == 0) { startingVersionForCSemVerFound = true; } else if (cmp > 0) { // This version is smaller than the StartingVersionForCSemVer: // we ignore it. return; } } TagCommit tagCommit; if (_collector.TryGetValue(c.Sha, out tagCommit)) { tagCommit.AddCollectedTag(v); } else { _collector.Add(c.Sha, tagCommit = new TagCommit(c, v)); } } }
public void AddSameTree(TagCommit otherCommit) { Debug.Assert(this != otherCommit); Debug.Assert((_nextSameTree == null && _headSameTree == null) || (_nextSameTree != null && _headSameTree != null && _nextSameTree._headSameTree == _headSameTree)); if (_headSameTree == null) { if (otherCommit._headSameTree == null) { _headSameTree = this; otherCommit._headSameTree = this; _nextSameTree = otherCommit; if (_thisTag.CompareTo(otherCommit._thisTag) < 0) { _bestTagCommit = otherCommit; } else { _bestTagCommit = this; } } else { otherCommit._headSameTree.AddSameTreeFromHead(this); } } else { _headSameTree.AddSameTreeFromHead(otherCommit); } }
void RegisterContent(TagCommit tagCommit) { TagCommit contentExists; if (_collector.TryGetValue(tagCommit.ContentSha, out contentExists)) { if (tagCommit != contentExists) { contentExists.AddSameTree(tagCommit); } } else { _collector.Add(tagCommit.ContentSha, tagCommit); } }
void RegisterOneTag(StringBuilder errors, Commit c, string tagName, Func <Commit, ReleaseTagParsingMode> analyseInvalidTagSyntax, ref bool startingVersionForCSemVerFound) { ReleaseTagParsingMode mode = analyseInvalidTagSyntax == null ? ReleaseTagParsingMode.IgnoreMalformedTag : analyseInvalidTagSyntax(c); ReleaseTagVersion v = ReleaseTagVersion.TryParse(tagName, mode == ReleaseTagParsingMode.RaiseErrorOnMalformedTag); if (v.IsMalformed) { // Parsing in strict mode can result in malformed tag. We can not assume that here: // Debug.Assert( mode == ReleaseTagParsingMode.RaiseErrorOnMalformedTag ); if (mode == ReleaseTagParsingMode.RaiseErrorOnMalformedTag) { errors.AppendFormat("Malformed {0} on commit '{1}'.", v.ParseErrorMessage, c.Sha).AppendLine(); } return; } if (v.IsValid) { if (_startingVersionForCSemVer != null) { int cmp = _startingVersionForCSemVer.CompareTo(v); if (cmp == 0) { startingVersionForCSemVerFound = true; } else if (cmp > 0) { // This version is smaller than the StartingVersionForCSemVer: // we ignore it. return; } } if (mode == ReleaseTagParsingMode.RaiseErrorOnMalformedTagAndNonStandardPreReleaseName && v.IsPreRelease && !v.IsPreReleaseNameStandard) { errors.AppendFormat("Invalid PreRelease name in '{0}' on commit '{1}'.", v.OriginalTagText, c.Sha).AppendLine(); return; } TagCommit tagCommit; if (_collector.TryGetValue(c.Sha, out tagCommit)) { tagCommit.AddCollectedTag(v); } else { _collector.Add(c.Sha, tagCommit = new TagCommit(c, v)); } } }
void AddSameTreeFromHead(TagCommit other) { Debug.Assert(_headSameTree == this && _bestTagCommit != null); if (other._headSameTree == null) { other._headSameTree = this; other._nextSameTree = _nextSameTree; _nextSameTree = other; Debug.Assert(other._bestTagCommit == null); if (_bestTagCommit._thisTag.CompareTo(other._thisTag) < 0) { _bestTagCommit = other; } } else { var firstOther = other._headSameTree; Debug.Assert(firstOther._bestTagCommit != null); if (_bestTagCommit._thisTag.CompareTo(firstOther._bestTagCommit._thisTag) < 0) { _bestTagCommit = firstOther; } var n = firstOther; for ( ; ;) { n._headSameTree = this; if (n._nextSameTree == null) { break; } n = n._nextSameTree; } n._nextSameTree = _nextSameTree; _nextSameTree = firstOther; } }
void RegisterContent( TagCommit tagCommit ) { TagCommit contentExists; if( _collector.TryGetValue( tagCommit.ContentSha, out contentExists ) ) { if( tagCommit != contentExists ) contentExists.AddSameTree( tagCommit ); } else _collector.Add( tagCommit.ContentSha, tagCommit ); }
void RegisterOneTag( StringBuilder errors, Commit c, string tagName, Func<Commit, ReleaseTagParsingMode> analyseInvalidTagSyntax, ref bool startingVersionForCSemVerFound ) { ReleaseTagParsingMode mode = analyseInvalidTagSyntax == null ? ReleaseTagParsingMode.IgnoreMalformedTag : analyseInvalidTagSyntax( c ); ReleaseTagVersion v = ReleaseTagVersion.TryParse( tagName, mode == ReleaseTagParsingMode.RaiseErrorOnMalformedTag ); if( v.IsMalformed ) { // Parsing in strict mode can result in malformed tag. We can not assume that here: // Debug.Assert( mode == ReleaseTagParsingMode.RaiseErrorOnMalformedTag ); if( mode == ReleaseTagParsingMode.RaiseErrorOnMalformedTag ) { errors.AppendFormat( "Malformed {0} on commit '{1}'.", v.ParseErrorMessage, c.Sha ).AppendLine(); } return; } if( v.IsValid ) { if( _startingVersionForCSemVer != null ) { int cmp = _startingVersionForCSemVer.CompareTo( v ); if( cmp == 0 ) startingVersionForCSemVerFound = true; else if( cmp > 0 ) { // This version is smaller than the StartingVersionForCSemVer: // we ignore it. return; } } if( mode == ReleaseTagParsingMode.RaiseErrorOnMalformedTagAndNonStandardPreReleaseName && v.IsPreRelease && !v.IsPreReleaseNameStandard ) { errors.AppendFormat( "Invalid PreRelease name in '{0}' on commit '{1}'.", v.OriginalTagText, c.Sha ).AppendLine(); return; } TagCommit tagCommit; if( _collector.TryGetValue( c.Sha, out tagCommit ) ) { tagCommit.AddCollectedTag( v ); } else _collector.Add( c.Sha, tagCommit = new TagCommit( c, v ) ); } }
void SetBestTagCommit(TagCommit c) { Debug.Assert(c != null); _altBestTagCommit = _bestTagCommit ?? this; _bestTagCommit = c; }
void AddSameTreeFromHead( TagCommit other ) { Debug.Assert( _headSameTree == this && _bestTagCommit != null ); if( other._headSameTree == null ) { other._headSameTree = this; other._nextSameTree = _nextSameTree; _nextSameTree = other; Debug.Assert( other._bestTagCommit == null ); if( _bestTagCommit._thisTag.CompareTo( other._thisTag ) < 0 ) _bestTagCommit = other; } else { var firstOther = other._headSameTree; Debug.Assert( firstOther._bestTagCommit != null ); if( _bestTagCommit._thisTag.CompareTo( firstOther._bestTagCommit._thisTag ) < 0 ) _bestTagCommit = firstOther; var n = firstOther; for( ; ; ) { n._headSameTree = this; if( n._nextSameTree == null ) break; n = n._nextSameTree; } n._nextSameTree = _nextSameTree; _nextSameTree = firstOther; } }
public void AddSameTree( TagCommit otherCommit ) { Debug.Assert( this != otherCommit ); Debug.Assert( (_nextSameTree == null && _headSameTree == null) || (_nextSameTree != null && _headSameTree != null && _nextSameTree._headSameTree == _headSameTree) ); if( _headSameTree == null ) { if( otherCommit._headSameTree == null ) { _headSameTree = this; otherCommit._headSameTree = this; _nextSameTree = otherCommit; if( _thisTag.CompareTo( otherCommit._thisTag ) < 0 ) _bestTagCommit = otherCommit; else _bestTagCommit = this; } else otherCommit._headSameTree.AddSameTreeFromHead( this ); } else _headSameTree.AddSameTreeFromHead( otherCommit ); }