Ejemplo n.º 1
0
 /// <inheritdoc />
 protected override MdBlock GetEntryDetailHeaderBlock(ChangeLogEntry entry)
 {
     // in GitLab releases, the top heading is <h4> because higher
     // levels are used by the surrounding GitLab Web UI
     // => the header for individual entries is the level of the "details" header +1 => 5
     return(new MdHeading(5, GetSummaryText(entry)));
 }
Ejemplo n.º 2
0
        public ChangeLogEntryViewModel(ChangeLogConfiguration configuration, ChangeLogEntry model)
        {
            m_Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
            m_Model         = model ?? throw new ArgumentNullException(nameof(model));

            Footers = m_Model.Footers.Select(x => new ChangeLogEntryFooterViewModel(m_Configuration, x)).ToArray();
        }
Ejemplo n.º 3
0
        private async Task ProcessEntryAsync(IGitLabClient githubClient, ChangeLogEntry entry)
        {
            m_Logger.LogDebug($"Adding links to entry {entry.Commit}");

            var webUri = await TryGetWebUriAsync(githubClient, entry.Commit);

            if (webUri != null)
            {
                entry.CommitWebUri = webUri;
            }
            else
            {
                m_Logger.LogWarning($"Failed to determine web uri for commit '{entry.Commit}'");
            }


            foreach (var footer in entry.Footers)
            {
                if (TryParseReference(footer.Value, out var type, out var projectPath, out var id))
                {
                    var uri = await TryGetWebUriAsync(githubClient, type.Value, projectPath, id);

                    if (uri != null)
                    {
                        footer.WebUri = uri;
                    }
                    else
                    {
                        m_Logger.LogWarning($"Failed to determine web uri for GitLab {type} reference '{footer.Value}'");
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private static void ExecAction(object obj)
        {
            ICommand command = null;

            switch (obj)
            {
            case InitArgs args:
                var settings = new ProjectSettings(args.ProjectName, args.RootDirectory, args.IssueUrl);
                command = new InitCommand(settings);
                break;

            case AddArgs args:
                var changeLogEntry = new ChangeLogEntry(args.Description, args.Author, args.IssueId, args.Type);
                command = new AddCommand(changeLogEntry);
                break;

            case MergeArgs _:
                command = new MergeCommand();
                break;
            }

            if (command != null)
            {
                command.Execute();
            }
        }
Ejemplo n.º 5
0
        private async Task ProcessEntryAsync(IGitHubClient githubClient, ChangeLogEntry entry)
        {
            m_Logger.LogDebug($"Adding links to entry {entry.Commit}");

            var webUri = await TryGetWebUriAsync(githubClient, entry.Commit);

            if (webUri != null)
            {
                entry.CommitWebUri = webUri;
            }
            else
            {
                m_Logger.LogWarning($"Failed to determine web uri for commit '{entry.Commit}'");
            }

            foreach (var footer in entry.Footers)
            {
                if (TryParseReference(footer.Value, out var owner, out var repo, out var id))
                {
                    var uri = await TryGetWebUriAsync(githubClient, owner, repo, id);

                    if (uri != null)
                    {
                        footer.WebUri = uri;
                    }
                    else
                    {
                        m_Logger.LogWarning($"Failed to determine web uri for reference '{owner}/{repo}#{id}'");
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Determines whether the specified entry matches the filter expression.
        /// </summary>
        /// <param name="entry">The entry to evaluate the filter expression for.</param>
        /// <returns>Returns <c>true</c> if the entry matches the filter expression, otherwise returns <c>false</c></returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="entry"/> is <c>null</c></exception>
        public bool IsMatch(ChangeLogEntry entry)
        {
            if (entry is null)
            {
                throw new ArgumentNullException(nameof(entry));
            }

            return(m_MatchType(entry) && m_MatchScope(entry));
        }
Ejemplo n.º 7
0
        void DrawMainPanel()
        {
            if (currentIndex < 0)
            {
                return;
            }

            int versionIndexToRemove = -1;
            int indexToRemove        = -1;

            dataScroll = GUILayout.BeginScrollView(dataScroll);
            {
                ChangeLogEntry log = changeLogData.versions[currentIndex];

                log.versionId   = EditorGUILayout.TextField("Version Number", log.versionId);
                log.versionName = EditorGUILayout.TextField("Version Name", log.versionName);

                if (GUILayout.Button("Add"))
                {
                    log.changes.Add("");
                }


                for (int index = 0; index < log.changes.Count; index++)
                {
                    GUILayout.BeginHorizontal();
                    {
                        log.changes[index] = EditorGUILayout.TextField(log.changes[index]);

                        if (GUILayout.Button("X", GUILayout.Width(50)))
                        {
                            indexToRemove = index;
                        }
                    }
                    GUILayout.EndHorizontal();
                }

                if (indexToRemove >= 0)
                {
                    log.changes.RemoveAt(indexToRemove);
                }
            }
            GUILayout.EndScrollView();

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Delete Entry"))
            {
                versionIndexToRemove = currentIndex;
            }

            if (versionIndexToRemove != -1)
            {
                changeLogData.versions.RemoveAt(versionIndexToRemove);
                currentIndex = -1;
            }
        }
Ejemplo n.º 8
0
        public ChangeLogEntryReferenceTextElement(string text, ChangeLogEntry entry)
        {
            if (String.IsNullOrWhiteSpace(text))
            {
                throw new ArgumentException("Value must not be null or whitespace", nameof(text));
            }

            Text  = text;
            Entry = entry ?? throw new ArgumentNullException(nameof(entry));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Determines whether the specified entry should be included in the output.
        /// </summary>
        /// <remarks>
        /// A entry is included if it is matched by *any* of the 'include' expressions and *not* by any of the 'exclude' expressions.
        /// </remarks>
        /// <param name="entry">The entry to evaluate the filter for.</param>
        /// <returns>Returns <c>true</c> if the entry was matched by the filter, otherwise returns <c>false</c></returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="entry"/> is <c>null</c></exception>
        public bool IsIncluded(ChangeLogEntry entry)
        {
            if (entry is null)
            {
                throw new ArgumentNullException(nameof(entry));
            }

            return(m_IncludeExpressions.Any(expr => expr.IsMatch(entry)) &&
                   !m_ExcludeExpressions.Any(expr => expr.IsMatch(entry)));
        }
Ejemplo n.º 10
0
        public void ContainsBreakingChanges_is_true_when_commit_message_was_marked_as_breaking_change()
        {
            // ARRANGE
            var commitMessage = GetCommitMessage(isBreakingChange: true);

            // ACT
            var changelogEntry = ChangeLogEntry.FromCommitMessage(GetGitCommit(), commitMessage);

            // ASSERT
            Assert.True(changelogEntry.ContainsBreakingChanges);
        }
Ejemplo n.º 11
0
        public void ContainsBreakingChanges_is_true_when_commit_message_contains_a_breaking_change_footer()
        {
            // ARRANGE
            var commitMessage = GetCommitMessage(footers: new[] { new CommitMessageFooter(CommitMessageFooterName.BreakingChange, "some breaking change") });

            // ACT
            var changelogEntry = ChangeLogEntry.FromCommitMessage(GetGitCommit(), commitMessage);

            // ASSERT
            Assert.True(changelogEntry.ContainsBreakingChanges);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Gets the display name for the entry's scope.
        /// </summary>
        /// <returns>
        /// Returns the display name for the entry's scope as configured in <paramref name="configuration"/>.
        /// If the entry has no scope, returns null.
        /// If no display name is configured for the scope, returns the scope itself.
        /// </returns>
        public static string?GetScopeDisplayName(this ChangeLogEntry entry, ChangeLogConfiguration configuration)
        {
            if (String.IsNullOrEmpty(entry.Scope))
            {
                return(null);
            }

            var displayName = configuration.Scopes.FirstOrDefault(scope => StringComparer.OrdinalIgnoreCase.Equals(scope.Name, entry.Scope))?.DisplayName;

            return(!String.IsNullOrWhiteSpace(displayName) ? displayName : entry.Scope);
        }
Ejemplo n.º 13
0
        public void Footers_does_not_return_breaking_changes_footers_01()
        {
            // ARRANGE
            var commitMessage = GetCommitMessage(footers: new[] { new CommitMessageFooter(CommitMessageFooterName.BreakingChange, "some breaking change") });

            // ACT
            var changelogEntry = ChangeLogEntry.FromCommitMessage(GetGitCommit(), commitMessage);

            // ASSERT
            Assert.Empty(changelogEntry.Footers);
        }
Ejemplo n.º 14
0
        void CreateTag(ChangeLogEntry lastVersion, string currentDirectory)
        {
            var tagMessage   = string.Join(Environment.NewLine, lastVersion.Bullets.Select(text => $"* {text}"));
            var tempFilePath = Path.GetTempFileName();

            File.WriteAllText(tempFilePath, tagMessage, Encoding.UTF8);

            Console.WriteLine($"Tag message written to {tempFilePath}");

            ShellExecute(currentDirectory, "git", $@"tag {lastVersion.Version} -a -F ""{tempFilePath}""");

            ShellExecute(currentDirectory, "git", @"push --tags");
        }
Ejemplo n.º 15
0
        public void BreakingChanges_returns_descriptions_of_breaking_changes()
        {
            // ARRANGE
            var commitMessage = GetCommitMessage(footers: new[] { new CommitMessageFooter(CommitMessageFooterName.BreakingChange, "some breaking change") });

            // ACT
            var changelogEntry = ChangeLogEntry.FromCommitMessage(GetGitCommit(), commitMessage);

            // ASSERT
            var description = Assert.Single(changelogEntry.BreakingChangeDescriptions);

            Assert.Equal("some breaking change", description);
        }
Ejemplo n.º 16
0
        void OnGUI()
        {
            GUILayout.BeginHorizontal();
            {
                GUILayout.BeginVertical("box", GUILayout.Width(optionAreaWidth));
                {
                    DrawOptionsArea();

                    if (GUILayout.Button("Add New"))
                    {
                        ChangeLogEntry changeLogVersion = new ChangeLogEntry();
                        changeLogData.versions.Add(changeLogVersion);
                    }

                    if (GUILayout.Button("Save"))
                    {
                        EditorUtility.SetDirty(changeLogData);
                    }

                    if (GUILayout.Button("Export As Json"))
                    {
                        string json = JsonConvert.SerializeObject(changeLogData, Formatting.Indented);
                        using (StreamWriter writer = new StreamWriter(Path.Combine(Application.streamingAssetsPath, "ChangeLog.json")))
                        {
                            writer.Write(json);
                        }
                        Debug.Log(json);
                    }

                    if (GUILayout.Button("Import Json"))
                    {
                        string path = EditorUtility.OpenFilePanel("Load Json Text file", "", "txt");
                        if (path.Length != 0)
                        {
                            string        fileContent = File.ReadAllText(path);
                            ChangeLogData data        = JsonConvert.DeserializeObject <ChangeLogData>(fileContent);
                            changeLogData.versions = data.versions;
                        }
                    }
                }
                GUILayout.EndVertical();

                GUILayout.Space(10);
                GUILayout.BeginVertical("box");
                {
                    DrawMainPanel();
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 17
0
        public void Footers_does_not_return_breaking_changes_footers_02()
        {
            // ARRANGE
            var commitMessage = GetCommitMessage(footers: new[] { new CommitMessageFooter(new CommitMessageFooterName("some-footer"), "some breaking change") });

            // ACT
            var changelogEntry = ChangeLogEntry.FromCommitMessage(GetGitCommit(), commitMessage);

            // ASSERT
            var footer = Assert.Single(changelogEntry.Footers);

            Assert.Equal(new CommitMessageFooterName("some-footer"), footer.Name);
            Assert.Equal("some breaking change", footer.Value.Text);
        }
Ejemplo n.º 18
0
        private bool TryGetChangeLogEntry(GitCommit commit, [NotNullWhen(true)] out ChangeLogEntry?entry)
        {
            var strictMode = m_Configuration.Parser.Mode == ChangeLogConfiguration.ParserMode.Strict;

            try
            {
                var parsed = CommitMessageParser.Parse(commit.CommitMessage, strictMode);
                entry = ChangeLogEntry.FromCommitMessage(commit, parsed);
                return(true);
            }
            catch (ParserException)
            {
                m_Logger.LogDebug($"Ignoring commit '{commit.Id}' because the commit message could not be parsed.");
                entry = default;
                return(false);
            }
        }
        internal void SaveChangelogEntry(ChangeLogEntry entry)
        {
            var serializer = new SerializerBuilder()
                             .EmitDefaults()
                             .Build();

            string content  = serializer.Serialize(entry);
            var    filePath = Path.Join(settings.RootDirectory, ProjectStructureConstants.ChangelogEntriesDirectory, entry.IssueId + ".yml");

            try
            {
                File.WriteAllText(filePath, content);
            }
            catch (DirectoryNotFoundException e)
            {
                throw new ProjectStructureFaultyException($"Could not save changlog entry: {e.Message}");
            }
        }
Ejemplo n.º 20
0
 internal XunitSerializableChangeLogEntry(ChangeLogEntry value) => Value = value;
Ejemplo n.º 21
0
 /// <summary>
 /// Gets the HTML id for the details section of the specified entry
 /// </summary>
 protected abstract string GetHtmlHeadingId(ChangeLogEntry entry);
Ejemplo n.º 22
0
 /// <inheritdoc />
 protected override string GetHtmlHeadingId(ChangeLogEntry entry) => $"changelog-heading-{entry.Commit}";
Ejemplo n.º 23
0
 /// <inheritdoc />
 protected override string GetHtmlHeadingId(ChangeLogEntry entry)
 {
     // use default header ids generated by GitLab instead of setting a header explicitly
     return(new MdHeading(1, GetSummaryText(entry)).Anchor ?? "");
 }
Ejemplo n.º 24
0
 public void SetEntry(ChangeLogEntry entryData)
 {
     text.text = $"---------------------------------------------------\n\nDate: {entryData.date} \n\rAuthor: {entryData.author} " +
                 $"\n\r\n\rCommit: {entryData.commit} \n\r\n\rMessage: {entryData.message}";
 }
Ejemplo n.º 25
0
 public AddCommand(ChangeLogEntry changlogEntry)
 {
     this.changlogEntry = changlogEntry;
 }
Ejemplo n.º 26
0
 /// <inheritdoc />
 protected override MdBlock GetEntryDetailHeaderBlock(ChangeLogEntry entry)
 {
     // in GitHub releases, the top heading is <h2> because higher,
     // => the header for individual entries is the level of the "details" header + 1 => 3
     return(new MdHeading(3, GetSummaryText(entry)));
 }
Ejemplo n.º 27
0
        private async Task ProcessEntryAsync(IGitLabClient gitlabClient, GitLabProjectInfo projectInfo, ChangeLogEntry entry)
        {
            m_Logger.LogDebug($"Adding links to entry {entry.Commit}");

            foreach (var footer in entry.Footers)
            {
                if (footer.Value is CommitReferenceTextElement commitReference)
                {
                    var uri = await TryGetWebUriAsync(gitlabClient, projectInfo, commitReference.CommitId);

                    if (uri is not null)
                    {
                        footer.Value = CommitReferenceTextElementWithWebLink.FromCommitReference(commitReference, uri);
                    }
                    else
                    {
                        m_Logger.LogWarning($"Failed to determine web uri for commit '{entry.Commit}'");
                    }
                }
                else if (footer.Value is PlainTextElement && GitLabReference.TryParse(footer.Value.Text, projectInfo, out var reference))
                {
                    var uri = await TryGetWebUriAsync(gitlabClient, reference);

                    if (uri is not null)
                    {
                        footer.Value = new GitLabReferenceTextElement(footer.Value.Text, uri, projectInfo, reference);
                    }
                    else
                    {
                        m_Logger.LogWarning($"Failed to determine web uri for GitLab reference '{reference}'");
                    }
                }
            }
        }