/// <summary> /// Initializes a new <see cref="TagCollector"/>. /// Errors may be appended to the collector that can be syntaxic errors or multiple different versions applied to the same commit point. /// </summary> /// <param name="errors">A collector of errors. One line per error.</param> /// <param name="repo">The Git repository.</param> /// <param name="startingVersionForCSemVer">Vesion tags lower than this version will be ignored.</param> /// <param name="overriddenTags">Optional commits with associated tags that are applied as if they exist in the repository.</param> /// <param name="singleMajor">Optional major filter.</param> /// <param name="checkValidExistingVersions"> /// When true, existing versions are checked: one of the valid first version must exist and exisitng versions /// must be compact. /// </param> public TagCollector( StringBuilder errors, Repository repo, string startingVersionForCSemVer = null, IEnumerable <KeyValuePair <string, IReadOnlyList <string> > > overriddenTags = null, int?singleMajor = null, bool checkValidExistingVersions = false) { Debug.Assert(errors != null && repo != null); _collector = new Dictionary <string, TagCommit>(); if (startingVersionForCSemVer != null) { _startingVersionForCSemVer = CSVersion.TryParse(startingVersionForCSemVer, true); if (!_startingVersionForCSemVer.IsValid) { errors.Append("Invalid StartingVersionForCSemVer. ").Append(_startingVersionForCSemVer.ErrorMessage).AppendLine(); return; } if (singleMajor.HasValue && _startingVersionForCSemVer.Major != singleMajor) { errors.Append("StartingVersionForCSemVer '") .Append(_startingVersionForCSemVer) .Append("': since it is defined, its major must be ").Append(singleMajor).Append(" that is the SingleMajor set.") .AppendLine(); return; } } // Register all tags. RegisterAllTags(errors, repo, overriddenTags, singleMajor); // Resolves multiple tags on the same commit. CloseCollect(errors); // Sorts TagCommit, optionally checking the existing versions. _repoVersions = new RepositoryVersions(_collector.Values, errors, _startingVersionForCSemVer, checkValidExistingVersions); // Register content. if (errors.Length == 0) { foreach (var tc in _repoVersions.TagCommits) { RegisterContent(tc); } } }
/// <summary> /// Initializes a new <see cref="TagCollector"/>. /// Errors may be appended to the collector that can be syntaxic errors or multiple different versions applied to the same commit point. /// </summary> /// <param name="errors">A collector of errors. One line per error.</param> /// <param name="repo">The Git repository.</param> /// <param name="startingVersionForCSemVer">Vesion tags lower than this version will be ignored.</param> /// <param name="analyseInvalidTagSyntax"> /// Optional function that drives the behavior regarding malformed tags of commits. /// When null, <see cref="ReleaseTagParsingMode.IgnoreMalformedTag">IgnoreMalformedTag</see> is used for all tags. /// </param> /// <param name="OverriddenTags">Optional commits with associated tags that are applied as if they exist in the repository.</param> /// <param name="checkValidExistingVersions"> /// When true, existing versions are checked: one of the valid first version must exist and exisitng versions /// must be compact. /// </param> public TagCollector( StringBuilder errors, Repository repo, string startingVersionForCSemVer = null, Func <Commit, ReleaseTagParsingMode> analyseInvalidTagSyntax = null, IEnumerable <KeyValuePair <string, IReadOnlyList <string> > > OverriddenTags = null, bool checkValidExistingVersions = false) { Debug.Assert(errors != null && repo != null); _collector = new Dictionary <string, TagCommit>(); _versionsCache = new Dictionary <string, CommitVersionInfo>(); if (startingVersionForCSemVer != null) { _startingVersionForCSemVer = ReleaseTagVersion.TryParse(startingVersionForCSemVer, true); if (!_startingVersionForCSemVer.IsValid) { errors.Append("Invalid StartingVersionForCSemVer. ").Append(_startingVersionForCSemVer.ParseErrorMessage).AppendLine(); return; } } // Register all tags. RegisterAllTags(errors, repo, analyseInvalidTagSyntax, OverriddenTags); // Resolves multiple tags on the same commit. CloseCollect(errors); // Sorts TagCommit, optionally checking the existing versions. _repoVersions = new RepositoryVersions(_collector.Values, errors, _startingVersionForCSemVer, checkValidExistingVersions); // Register content. if (errors.Length == 0) { foreach (var tc in _repoVersions.TagCommits) { RegisterContent(tc); } } }
/// <summary> /// Initializes a new <see cref="TagCollector"/>. /// Errors may be appended to the collector that can be syntaxic errors or multiple different versions applied to the same commit point. /// </summary> /// <param name="errors">A collector of errors. One line per error.</param> /// <param name="repo">The Git repository.</param> /// <param name="startingVersionForCSemVer">Vesion tags lower than this version will be ignored.</param> /// <param name="analyseInvalidTagSyntax"> /// Optional function that drives the behavior regarding malformed tags of commits. /// When null, <see cref="ReleaseTagParsingMode.IgnoreMalformedTag">IgnoreMalformedTag</see> is used for all tags. /// </param> /// <param name="OverriddenTags">Optional commits with associated tags that are applied as if they exist in the repository.</param> /// <param name="checkValidExistingVersions"> /// When true, existing versions are checked: one of the valid first version must exist and exisitng versions /// must be compact. /// </param> public TagCollector( StringBuilder errors, Repository repo, string startingVersionForCSemVer = null, Func<Commit, ReleaseTagParsingMode> analyseInvalidTagSyntax = null, IEnumerable<KeyValuePair<string, IReadOnlyList<string>>> OverriddenTags = null, bool checkValidExistingVersions = false ) { Debug.Assert( errors != null && repo != null ); _collector = new Dictionary<string, TagCommit>(); _versionsCache = new Dictionary<string, CommitVersionInfo>(); if( startingVersionForCSemVer != null ) { _startingVersionForCSemVer = ReleaseTagVersion.TryParse( startingVersionForCSemVer, true ); if( !_startingVersionForCSemVer.IsValid ) { errors.Append( "Invalid StartingVersionForCSemVer. " ).Append( _startingVersionForCSemVer.ParseErrorMessage ).AppendLine(); return; } } // Register all tags. RegisterAllTags( errors, repo, analyseInvalidTagSyntax, OverriddenTags ); // Resolves multiple tags on the same commit. CloseCollect( errors ); // Sorts TagCommit, optionally checking the existing versions. _repoVersions = new RepositoryVersions( _collector.Values, errors, _startingVersionForCSemVer, checkValidExistingVersions ); // Register content. if( errors.Length == 0 ) { foreach( var tc in _repoVersions.TagCommits ) { RegisterContent( tc ); } } }