tomasbjerre / git-changelog-lib

Generate changelog, and/or next version, with, or without, conventional commits from a GIT repository
Apache License 2.0
199 stars 92 forks source link

Feature-request (or question): Issues by category #19

Closed spacecowboy closed 8 years ago

spacecowboy commented 8 years ago

Not sure if this is currently possible, but I am trying to achieve a changelog with categories, where each category is an issue source (each category is a custom issue). For example, the result I want is along these lines:

# My changelog

Changelog of my project

## [Next release](url)

### GitHub

* An issue [#123](url) in commit [abc124]
* An issue [#124](url) in commit [abc125]
* An issue [#125](url) in commit [abc126]
* An issue [#126](url) in commit [abc127]
* An issue [#127](url) in commit [abc128]

### CustomIssue1

* A custom issue in commit[abc234]
* A custom issue in commit[abc235]

### Other changes

* ...
* ...

To achieve this, I think you need to add under tags an item such as IssueTypes, where each type then has a name and issues.

Alternatively, the concept of a category could be a completely independent thing which you specify manually.

What do you think? Is there an easier way to achieve this with the existing implementation?

tomasbjerre commented 8 years ago

I think your idea with IssueType is good. Should be easy to implement and easy to understand for a user.

Issue #6 is sort of related. It is something that may be solved with an independent config. So that the changelog can group all changes to the database, an api-package...

I think both can be implemented. Den 17 mar 2016 16:43 skrev "Jonas Kalderstam" notifications@github.com:

Not sure if this is currently possible, but I am trying to achieve a changelog with categories, where each category is an issue source (each category is a custom issue). For example, the result I want is along these lines:

My changelog

Changelog of my project

Next release

GitHub

  • An issue #123 in commit [abc124]
  • An issue #124 in commit [abc125]
  • An issue #125 in commit [abc126]
  • An issue #126 in commit [abc127]
  • An issue #127 in commit [abc128]

CustomIssue1

  • A custom issue in commit[abc234]
  • A custom issue in commit[abc235]

Other changes

  • ...
  • ...

To achieve this, I think you need to add under tags an item such as IssueTypes, where each type then has a name and issues.

Alternatively, a concept of a category could be a completely independent thing wich you specify manually.

What do you think? Is there an easier way to achieve this with the existing implementation?

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/tomasbjerre/git-changelog-lib/issues/19

spacecowboy commented 8 years ago

Sort of yes. Our code base is not structured in such a way that we can use filetypes or folders though. A single commit might touch files in many different modules.

Another way would be to add a de-duplication option. Meaning the writer wouldn't create an identical section if it is already in that section.

tomasbjerre commented 8 years ago

https://github.com/tomasbjerre/git-changelog-lib/pull/20

Example here: https://github.com/tomasbjerre/git-changelog-lib/blob/feature/issuetypes/src/test/resources/assertions/testIssueTypesIssuesCommits.md

Wat do you think?

spacecowboy commented 8 years ago

Thanks for implementing it. Looks really nice! I pulled the changes and tried it out. Formatted the way I imagined.

tomasbjerre commented 8 years ago

I added title attribute to custom issues. WIth support for variables. To avoid the empty subject-lines that you found in the PR. Perhaps it can be released like this, if you dont have any other thoughts?

spacecowboy commented 8 years ago

I'm not sure how the Title value resolves it. Still getting the same result. Here's what I am using to experiment with so you can see what I see:

Repo: https://github.com/neo4j/neo4j.git

changelog.json:

{
 "templatePath": "changelog.json",

 "fromRepo": ".",
 "fromCommit": "4bbf2b543a0f04e496fab0e023ad385976924322",
 "toRef": "refs/remotes/origin/3.0",

 "ignoreCommitsIfMessageMatches": "^\\[maven-release-plugin\\].*|^\\[Gradle Release Plugin\\].*|^Merge.*",
 "readableTagName": "/([^/]+?)$",
 "dateFormat": "YYYY-MM-dd HH:mm:ss",
 "untaggedName": "Next release",
 "noIssueName": "Other changes",
 "timeZone": "UTC",
 "removeIssueFromMessage": "false",

 "_comment_gitHubApi": "https://api.github.com/repos/neo4j/neo4j",
 "_comment_gitHubIssuePattern": "#([0-9]+)",

 "customIssues": [
  { "name": "Incident", "pattern": "INC[0-9]*", "link": "http://inc/${PATTERN_GROUP}" },
  { "name": "CQ", "pattern": "CQ([0-9]+)", "link": "http://cq/${PATTERN_GROUP_1}" },
     { "name": "Bugs", "pattern": "#bug" },
     { "name": "Import tool", "pattern": "#import-tool.*#([0-9]+)|#([0-9]+).*#import-tool" },
     { "name": "Cypher", "pattern": "cypher"},
     { "name": "Consistency checker", "pattern": "consistency checker"},
     { "name": "Bolt", "pattern": "bolt"},
     { "name": "HA", "pattern": "\bha\b|cluster"},
     { "name": "Packaging", "pattern": "powershell"},
     { "name": "NestedTest", "pattern": "index.*#([0-9]+)|#([0-9+]).*index", "link": "https://github.com/neo4j/neo4j/issues/${PATTERN_GROUP_1}"}
 ]
}

changelog.mustache:

# Neo4j changelog

Changelog of Neo4j                                                                                                                                                        

{{#tags}}                                                                                                                                                                 

## [{{name}}](https://github.com/neo4j/neo4j/releases/tag/{{name}})                                                                                                       

  {{#issueTypes}}                                                                                                                                                         

### {{name}}                                                                                                                                                              

    {{#issues}}                                                                                                                                                           
      {{#hasIssue}}                                                                                                                                                       
        {{#hasLink}}                                                                                                                                                      
          {{#commits}}                                                                                                                                                    
* {{{messageTitle}}} [{{hash}}](https://github.com/neo4j/neo4j/commit/{{hash}}), [{{issue}}]({{link}})                                                                    
          {{/commits}}                                                                                                                                                    
        {{/hasLink}}                                                                                                                                                      
        {{^hasLink}}                                                                                                                                                      
         {{#commits}}                                                                                                                                                     
* {{{messageTitle}}} [{{hash}}](https://github.com/neo4j/neo4j/commit/{{hash}}) No link for {{issue}}                                                                     
         {{/commits}}                                                                                                                                                     
        {{/hasLink}}                                                                                                                                                      
      {{/hasIssue}}                                                                                                                                                       
    {{/issues}}                                                                                                                                                           
  {{/issueTypes}}                                                                                                                                                         
{{/tags}}                       

And for what it's worth, this is what I am trying to approximate: https://github.com/neo4j/neo4j/wiki/Neo4j-3.0-changelog

UPDATE: Fixed mustache template

tomasbjerre commented 8 years ago

Your second paste there should have been a mustache template right? =) And in the first paste, you can now change:

{ "name": "Bugs", "pattern": "#bug" },
{ "name": "Import tool", "pattern": "#import-tool.*#([0-9]+)|#([0-9]+).*#import-tool" },

to:

{ "name": "Bugs", title:"Bugs", "pattern": "#bug" },
{ "name": "Import tool", title: "${PATTERN_GROUP}", "pattern": "#import-tool.*#([0-9]+)|#([0-9]+).*#import-tool" },
spacecowboy commented 8 years ago

Oh right. Fixed that..

But still, it doesn't change the empty 'Other fixes' section. With your suggested changes:

config:

{
 "templatePath": "changelog.json",

 "fromRepo": ".",
 "fromCommit": "4bbf2b543a0f04e496fab0e023ad385976924322",
 "toRef": "refs/remotes/origin/3.0",

 "ignoreCommitsIfMessageMatches": "^\\[maven-release-plugin\\].*|^\\[Gradle Release Plugin\\].*|^Merge.*",
 "readableTagName": "/([^/]+?)$",
 "dateFormat": "YYYY-MM-dd HH:mm:ss",
 "untaggedName": "Next release",
 "noIssueName": "Other changes",
 "timeZone": "UTC",
 "removeIssueFromMessage": "false",

 "_comment_gitHubApi": "https://api.github.com/repos/neo4j/neo4j",
 "_comment_gitHubIssuePattern": "#([0-9]+)",

 "customIssues": [
  { "name": "Incident", "pattern": "INC[0-9]*", "link": "http://inc/${PATTERN_GROUP}" },
     { "name": "CQ", "pattern": "CQ([0-9]+)", "link": "http://cq/${PATTERN_GROUP_1}" },
     { "name": "Bugs", "title":"Bugs", "pattern": "#bug" },
     { "name": "Import tool", "title": "${PATTERN_GROUP}", "pattern": "#import-tool.*#([0-9]+)|#([0-9]+).*#import-tool" },
     { "name": "Cypher", "pattern": "cypher"},
     { "name": "Consistency checker", "pattern": "consistency checker"},
     { "name": "Bolt", "pattern": "bolt", "title": "HA ${PATTERN_GROUP}"},
     { "name": "HA", "pattern": "\bha\b|cluster", "title": "HA ${PATTERN_GROUP}"},
     { "name": "Packaging", "pattern": "powershell"},
     { "name": "NestedTest", "pattern": "index.*#([0-9]+)|#([0-9+]).*index", "link": "https://github.com/neo4j/neo4j/issues/${PATTERN_GROUP_1}"}
 ]
}

template:

# Neo4j changelog

Changelog of Neo4j

{{#tags}}

## [{{name}}](https://github.com/neo4j/neo4j/releases/tag/{{name}})

  {{#issueTypes}}

### {{name}}

    {{#issues}}
      {{#hasIssue}}
        {{#hasTitle}}
          {{#commits}}
* {{{messageTitle}}} [{{hash}}](https://github.com/neo4j/neo4j/commit/{{hash}}), {{issue}} ({{title}})
          {{/commits}}
        {{/hasTitle}}
        {{^hasTitle}}
         {{#commits}}
* {{{messageTitle}}} [{{hash}}](https://github.com/neo4j/neo4j/commit/{{hash}}) No title for {{issue}}
         {{/commits}}
        {{/hasTitle}}
      {{/hasIssue}}
    {{/issues}}
  {{/issueTypes}}
{{/tags}}

Gives the following result:

# Neo4j changelog

Changelog of Neo4j

## [Next release](https://github.com/neo4j/neo4j/releases/tag/Next release)

### Bolt

* Query logging of user name and connection details for bolt [a5ea31926255deb](https://github.com/neo4j/neo4j/commit/a5ea31926255deb), bolt (HA bolt)
* Fix bolt BasicAuthentication tests [07f60d3d7429f02](https://github.com/neo4j/neo4j/commit/07f60d3d7429f02), bolt (HA bolt)
* Setting bolt enabled by default [5546f7ed2584f37](https://github.com/neo4j/neo4j/commit/5546f7ed2584f37), bolt (HA bolt)

### Consistency checker

* Simply use logs_directory for consistency checker reports instead of delegating the setting. [70683d14eda3458](https://github.com/neo4j/neo4j/commit/70683d14eda3458) No title for consistency checker
* Need to look in the right place for the consistency checker output. [5565d34acc53571](https://github.com/neo4j/neo4j/commit/5565d34acc53571) No title for consistency checker
* Put the consistency checker report in the logs directory. [6498dd197e14ab4](https://github.com/neo4j/neo4j/commit/6498dd197e14ab4) No title for consistency checker

### HA

* Remove lingering fromXml cluster provider use [f50f609ac19efe0](https://github.com/neo4j/neo4j/commit/f50f609ac19efe0), cluster (HA cluster)
* Make sure tests don't mask errors on cluster shutdown [50638eaa7bbf3f2](https://github.com/neo4j/neo4j/commit/50638eaa7bbf3f2), cluster (HA cluster)
* Increase cluster test robustness using variable ports [c90e8c500cde914](https://github.com/neo4j/neo4j/commit/c90e8c500cde914), cluster (HA cluster)
* Increase cluster test robustness using variable ports [c90e8c500cde914](https://github.com/neo4j/neo4j/commit/c90e8c500cde914), cluster (HA cluster)
* 6 minutes faster server enterprise tests [7095c28148fed2f](https://github.com/neo4j/neo4j/commit/7095c28148fed2f), cluster (HA cluster)
* Retire the ha.cluster_join_timeout setting which logically duplicated ha.join_timeout [d6cdf3f9a748f30](https://github.com/neo4j/neo4j/commit/d6cdf3f9a748f30), cluster (HA cluster)

### Other changes

### Packaging

* Update Procrun commands in powershell [52c55de5043a409](https://github.com/neo4j/neo4j/commit/52c55de5043a409) No title for powershell
* Replace Windows Service Wrapper with ACD ProcRun [6f42fae5d49a821](https://github.com/neo4j/neo4j/commit/6f42fae5d49a821) No title for powershell
...

Still an empty "Other changes" section in there as you see.

The customTitle feature thing is really useful though, (didn't realise how important this was previously). As it allows one to write commit messages which include stuff like:

changelog:Bugs:Fixed #99

changelog:Features:Made it faster #101

But you know what would solve it (maybe it already exists?), a hasIssues or hasCommits flag in each issueType. Then the template would be modified as:

# Neo4j changelog

Changelog of Neo4j

{{#tags}}

## [{{name}}](https://github.com/neo4j/neo4j/releases/tag/{{name}})

  {{#issueTypes}}

  {{#hasIssues}}
### {{name}}

    {{#issues}}
      {{#hasIssue}}
        {{#hasTitle}}
          {{#commits}}
* {{{messageTitle}}} [{{hash}}](https://github.com/neo4j/neo4j/commit/{{hash}}), {{issue}} ({{title}})
          {{/commits}}
        {{/hasTitle}}
        {{^hasTitle}}
         {{#commits}}
* {{{messageTitle}}} [{{hash}}](https://github.com/neo4j/neo4j/commit/{{hash}}) No title for {{issue}}
         {{/commits}}
        {{/hasTitle}}
      {{/hasIssue}}
    {{/issues}}

  {{/hasIssues}}

  {{/issueTypes}}
{{/tags}}
tomasbjerre commented 8 years ago

Actually, in your first template, there are issues and commits in Other changes. Its just that none of them has the issue attribute set. Removing the {{#hasIssue}} will make them appear.

These issues only has a name (Other changes). Each issue has a name, title, issue and link. And the issue would resolve to a Jira like "JIRA-ABC" or for GitHub maby "#1234".

The issueType can never be empty. It it is there, then there are issues in it.

spacecowboy commented 8 years ago

Sure, but I dont want to list every commit. Every release will have hundreds of commits, making the changelog unreadable.

On Sat, Mar 19, 2016, 18:13 Tomas Bjerre notifications@github.com wrote:

Actually, in your first template, there are issues and commits in Other changes. Its just that none of them has the issue attribute set. Removing the {{#hasIssue}} will make them appear.

These issues only has a name (Other changes). Each issue has a name, title, issue and link. And the issue would resolve to a Jira like "JIRA-ABC" or for GitHub maby "#1234".

The issueType can never be empty. It it is there, then there are issues in it.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/tomasbjerre/git-changelog-lib/issues/19#issuecomment-198750726

tomasbjerre commented 8 years ago

You can use the ignoreCommitsIfMessageMatches to filter out commits that should not be included.

spacecowboy commented 8 years ago

Sure. But it feels a bit redundant, as it will simply be the AND of each custom issue pattern, inversed. So it can grow quite large indeed :)

On Sat, Mar 19, 2016, 21:27 Tomas Bjerre notifications@github.com wrote:

You can use the ignoreCommitsIfMessageMatches to filter out commits that should not be included.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/tomasbjerre/git-changelog-lib/issues/19#issuecomment-198779640

tomasbjerre commented 8 years ago

Is you use case as simple as "only include commits that are mapped by at least one issue" ? =)

spacecowboy commented 8 years ago

Exactly :)

tomasbjerre commented 8 years ago

Its in master now. I'll release it tomorrow.

tomasbjerre commented 8 years ago

This is released now, ok to close the issue?

spacecowboy commented 8 years ago

I think so

On Sun, Mar 20, 2016, 11:40 Tomas Bjerre notifications@github.com wrote:

This is released now, ok to close the issue?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/tomasbjerre/git-changelog-lib/issues/19#issuecomment-198892633