Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Jira integration #52

Merged
merged 8 commits into from
Mar 11, 2021
Merged

feat: add Jira integration #52

merged 8 commits into from
Mar 11, 2021

Conversation

evanchaoli
Copy link
Contributor

What does this do / why do we need it?

Jira is a popular project management system which can be used for tracking feature request and bug fix. Usually Jira has been filled with plenty of information which can be used to generate change log. To avoid effort of copy-paste things from Jira to git commit log, Jira integration should be very helpful.

How this PR fixes the problem?

This PR adds Jira integration. With including an Jira story id in git commit message, it can automatically fetch story type, summary and description from Jira, and user may include those info in change log.

What should your reviewer look out for in this PR?

Check lists

  • Test passed
  • Coding style (indentation, etc)

Additional Comments (if any)

{Please write here}

Which issue(s) does this PR fix?

@evanchaoli
Copy link
Contributor Author

@tsuyoshiwada Can you please take a look at this PR?

@coveralls
Copy link

coveralls commented Sep 23, 2019

Pull Request Test Coverage Report for Build 635345958

  • 119 of 135 (88.15%) changed or added relevant lines in 9 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.4%) to 75.583%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/git-chglog/config.go 27 29 93.1%
cmd/git-chglog/generator.go 0 2 0.0%
jira.go 16 18 88.89%
cmd/git-chglog/main.go 38 41 92.68%
commit_parser.go 30 37 81.08%
Files with Coverage Reduction New Missed Lines %
cmd/git-chglog/generator.go 1 0%
Totals Coverage Status
Change from base Build 635257549: 0.4%
Covered Lines: 1718
Relevant Lines: 2273

💛 - Coveralls

@wadackel
Copy link
Member

@evanchaoli

Thank you for contributing!!

I haven't used Jira so much, So I don't understand the use case well 😢
I'm afraid of unexpected degrations when I update git-chlog in the future.

@evanchaoli
Copy link
Contributor Author

@tsuyoshiwada I think Jira integration is a standalone module. If a user doesn't use it, it doesn't affect existing functionality at all.

@evanchaoli evanchaoli changed the title Add Jira integration feat: add Jira integration Sep 27, 2019
@evanchaoli
Copy link
Contributor Author

@tsuyoshiwada I have spent time updating tests, now all checks have passed. I also updated REAME.md, which will help you understand this feature. The logic is actually simple, if a Jira story can be matched from a commit header, then it auto fetches Jira data and store in Commit.JiraIssue, so that template may refer to those Jira data.

Can you please take a look. I really hope this PR get merged.

@pcsaito
Copy link

pcsaito commented Nov 27, 2019

This would be really nice!

@ghostsquad
Copy link
Collaborator

@evanchaoli can you rebase this please?

Copy link
Collaborator

@clok clok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evanchaoli Thank you for the contribution! We at @GoodwayGroup use Jira as our central tracking tool for our teams. This integration would fit in nicely with our SDLC. I left some feedback on the PR.

Can you please rebase from master? We have updated urfave/cli to v2 and this will require a minor change in your PR.

cmd/git-chglog/config.go Outdated Show resolved Hide resolved
cmd/git-chglog/main.go Outdated Show resolved Hide resolved
cmd/git-chglog/main.go Outdated Show resolved Hide resolved
cmd/git-chglog/main.go Outdated Show resolved Hide resolved
commit_parser.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@clok clok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for sticking with this PR @evanchaoli

I think there is a good feature being added here. I do have some further change requests after pulling locally and testing it out.

Building locally and running a standard command to generate the changelog for the git-chglog repo I am seeing the following error and trace. This is on mac osx 10.14 with go 1.15.

dsmith ~/github/forks/tmp/git-chglog (git::jira):
$ make build
go build -o git-chglog ./cmd/git-chglog
go: downloading github.com/andygrunwald/go-jira v1.13.0
go: downloading github.com/fatih/structs v1.0.0
go: downloading github.com/trivago/tgo v1.0.1
go: downloading github.com/dgrijalva/jwt-go v3.2.0+incompatible
go: downloading github.com/pkg/errors v0.8.0
go: downloading github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135

dsmith ~/github/forks/tmp/git-chglog (git::jira):
$ ./git-chglog
panic: runtime error: index out of range [2] with length 2

goroutine 1 [running]:
github.com/git-chglog/git-chglog.assignDynamicValues(0x1413540, 0xc0001fe380, 0xc0001fa570, 0x3, 0x3, 0xc0001fbbd0, 0x2, 0x2)
	/Users/dsmith/github/forks/tmp/git-chglog/utils.go:45 +0x2fb
github.com/git-chglog/git-chglog.(*commitParser).processHeader(0xc000218a80, 0xc0001fe380, 0xc000232215, 0x1b)
	/Users/dsmith/github/forks/tmp/git-chglog/commit_parser.go:194 +0x114
github.com/git-chglog/git-chglog.(*commitParser).parseCommit(0xc000218a80, 0xc000232139, 0x115, 0xc0001fe2a0)
	/Users/dsmith/github/forks/tmp/git-chglog/commit_parser.go:138 +0x389
github.com/git-chglog/git-chglog.(*commitParser).Parse(0xc000218a80, 0xc0002124a0, 0xb, 0x14bb7a7, 0x6, 0xc0002124a0, 0xb, 0xc0000d0fc0)
	/Users/dsmith/github/forks/tmp/git-chglog/commit_parser.go:106 +0x267
github.com/git-chglog/git-chglog.(*Generator).readUnreleased(0xc0000d1340, 0xc00019a800, 0xe, 0x10, 0xe, 0x10, 0x0)
	/Users/dsmith/github/forks/tmp/git-chglog/chglog.go:228 +0x7e
github.com/git-chglog/git-chglog.(*Generator).Generate(0xc0000d1340, 0x1548ee0, 0xc0000ae008, 0x0, 0x0, 0x0, 0x0)
	/Users/dsmith/github/forks/tmp/git-chglog/chglog.go:147 +0x11a
main.(*generatorImpl).Generate(0x17e98c8, 0xc0001fa120, 0x1548ee0, 0xc0000ae008, 0x0, 0x0, 0xc0000d0f40, 0xcc0000000149d580, 0xc0001c1c48)
	/Users/dsmith/github/forks/tmp/git-chglog/cmd/git-chglog/generator.go:23 +0x6f
main.(*CLI).Run(0xc0000c2690, 0x1550b00)
	/Users/dsmith/github/forks/tmp/git-chglog/cmd/git-chglog/cli.go:72 +0x15b
main.AppAction(0xc0000d0d00, 0xc0000a8e00, 0x10)
	/Users/dsmith/github/forks/tmp/git-chglog/cmd/git-chglog/main.go:225 +0x65c
github.com/urfave/cli/v2.(*App).RunContext(0xc00009f6c0, 0x1550740, 0xc0000b2008, 0xc0000981b0, 0x1, 0x1, 0x0, 0x0)
	/Users/dsmith/.gvm/pkgsets/go1.15/global/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:322 +0x70d
github.com/urfave/cli/v2.(*App).Run(...)
	/Users/dsmith/.gvm/pkgsets/go1.15/global/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:224
main.main()
	/Users/dsmith/github/forks/tmp/git-chglog/cmd/git-chglog/main.go:232 +0x77

It appears that this error stems from when you have JiraIssueId within the pattern_maps block, but there are no Jira supported patterns found. I created #110 to provide a follow up on this for the project to provide examples of different configs that demonstrate the features that are supported by the tool.

I think that a good path forward is rolling back the changes made to the .git-chglog/config.yml in this PR and following up on #110 with an example of how you are using the Jira integration.

Makefile Show resolved Hide resolved
README.md Show resolved Hide resolved
.chglog/config.yml Outdated Show resolved Hide resolved
commit_parser.go Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
@clok
Copy link
Collaborator

clok commented Mar 5, 2021

Further testing is showing that there is some other issue with how the config is generated when using the --init command.

Expected:

dsmith ~/github/grid (git::master):
$ git-chglog --init
? What is the URL of your repository? test
? What is your favorite style? github
? Choose the format of your favorite commit message <type>(<scope>): <subject>
? What is your favorite template style? keep-a-changelog
? Do you include Merge Commit in CHANGELOG? Yes
? Do you include Revert Commit in CHANGELOG? Yes
? In which directory do you output configuration files and templates? .chglog

✨  Configuration file and template generation completed!
  ✔ .chglog/config.yml
  ✔ .chglog/CHANGELOG.tpl.md

When running the same command on the same repo with the compiled version from this branch, this is what I am seeing:

dsmith ~/github/grid (git::master):
$ ../forks/tmp/git-chglog/git-chglog --init
? What is the URL of your repository? test
? What is your favorite style? github
? Choose the format of your favorite commit message <type>(<scope>): <subject> -- feat(core): Add new feature
? What is your favorite template style? keep-a-changelog -- https://github.com/git-chglog/example-type-scope-subject/blob/master/CHANGELOG.kac.md
? Do you include Merge Commit in CHANGELOG? Yes
? Do you include Revert Commit in CHANGELOG? Yes
? In which directory do you output configuration files and templates? .chglog
 ERROR  "<type>(<scope>): <subject> -- feat(core): Add new feature" is an invalid commit message format

@evanchaoli
Copy link
Contributor Author

evanchaoli commented Mar 8, 2021

ERROR "(): -- feat(core): Add new feature" is an invalid commit message format

I believe the error is a regression that is caused by #108 because change to survye.v2. I ran into same error with the master branch. Anyway I helped fix the error.

With my fix:

$ ./git-chglog --init
? What is the URL of your repository? https://mygitlab.com
? What is your favorite style? gitlab
? Choose the format of your favorite commit message <type>(<scope>): <subject>
? What is your favorite template style? standard
? Do you include Merge Commit in CHANGELOG? No
? Do you include Revert Commit in CHANGELOG? No
? In which directory do you output configuration files and templates? /tmp

✨  Configuration file and template generation completed!
  ✔ /tmp/config.yml
  ✔ /tmp/CHANGELOG.tpl.md

@evanchaoli
Copy link
Contributor Author

It appears that this error stems from when you have JiraIssueId within the pattern_maps block, but there are no Jira supported patterns found. I created #110 to provide a follow up on this for the project to provide examples of different configs that demonstrate the features that are supported by the tool.

The panic was caused by the bad pattern. Actually I fixed the bad pattern in our real configure file but forgot to update the commit. After fixed the pattern, it compatible with comments that is with or without a Jira story ID.

$ ./git-chglog
<a name="unreleased"></a>
## [Unreleased]

### Features
- Add Jira integration.
- Add --tag-filter-pattern flag.


<a name="v0.10.0"></a>
## [v0.10.0] - 2021-01-16
### Bug Fixes
- ignore only git-chglog binary in root and not subfolder

### Features
- Adds 'Custom' sort_type to CommitGroup ([#69](https://github.com/git-chglog/git-chglog/issues/69))
- enable tag_filter_pattern in config options ([#72](https://github.com/git-chglog/git-chglog/issues/72))
- switch from dep to go mod ([#85](https://github.com/git-chglog/git-chglog/issues/85))
- add option to filter commits in a case insensitive way
- add upperFirst template function
- Add emoji format and some formatters in variables

### Reverts
- Revert "ci: switches to personal GH Token for brew cross repo releases"
- ci: switches to personal GH Token for brew cross repo releases


<a name="0.9.1"></a>
## [0.9.1] - 2019-09-23

<a name="0.9.0"></a>
## [0.9.0] - 2019-09-23
### Bug Fixes
- Fixing tests on windows

### Features
- Add --tag-filter-pattern flag.


<a name="0.8.0"></a>
## [0.8.0] - 2019-02-23
### Features
- add the contains, hasPrefix, hasSuffix, replace, lower and upper functions to the template functions map


<a name="0.7.1"></a>
## [0.7.1] - 2018-11-10
### Bug Fixes
- Panic occured when exec --next-tag with HEAD with tag


<a name="0.7.0"></a>
## [0.7.0] - 2018-05-06
### Bug Fixes
- Remove accidentally added `Unreleased.Tag`

### Features
- Add URL of output example for template style
- Add `--next-tag` flag (experimental)


<a name="0.6.0"></a>
## [0.6.0] - 2018-05-04
### Features
- Add tag name header id for keep-a-changelog template


<a name="0.5.0"></a>
## [0.5.0] - 2018-05-04
### Bug Fixes
- Add unreleased commits section to keep-a-changelog template [#15](https://github.com/git-chglog/git-chglog/issues/15)

### Features
- Update template format to human readable
- Add `Unreleased` field to `RenderData`


<a name="0.4.0"></a>
## [0.4.0] - 2018-04-14
### Features
- Add support for Bitbucket


<a name="0.3.3"></a>
## [0.3.3] - 2018-04-07
### Features
- Change to kindly error message when git-tag does not exist


<a name="0.3.2"></a>
## [0.3.2] - 2018-04-02
### Bug Fixes
- Fix color output bug in windows help command


<a name="0.3.1"></a>
## [0.3.1] - 2018-03-15
### Bug Fixes
- fix preview string of commit subject


<a name="0.3.0"></a>
## [0.3.0] - 2018-03-12
### Features
- Add support for GitLab


<a name="0.2.0"></a>
## [0.2.0] - 2018-03-02
### Features
- Add template for `Keep a changelog` to the `--init` option
- Supports vim like `j/k` keybind with item selection of `--init`


<a name="0.1.0"></a>
## [0.1.0] - 2018-02-25
### Bug Fixes
- Fix a bug that `Commit.Revert.Header` is not converted by `GitHubProcessor`
- Fix error message when `Tag` can not be acquired
- Fix `Revert` of template created by Initializer

### Code Refactoring
- Refactor `Initializer` to testable

### Features
- Supports annotated git-tag and adds `Tag.Subject` field [#3](https://github.com/git-chglog/git-chglog/issues/3)
- Remove commit message preview on select format
- Add Git Basic to commit message format
- Add preview to the commit message format of `--init` option


<a name="0.0.2"></a>
## [0.0.2] - 2018-02-18

<a name="0.0.1"></a>
## 0.0.1 - 2018-02-18
### Bug Fixes
- Fix parsing of revert and body

### Code Refactoring
- Fix typo
- Change to return an error if corresponding commit is empty
- Refactor the main logic

### Features
- Add cli client
- Add commits in commit version struct
- Add config normalize process
- Add Next and Previous in Tag
- Add MergeCommits and RevertCommits
- First implement


[Unreleased]: https://github.com/git-chglog/git-chglog/compare/v0.10.0...HEAD
[v0.10.0]: https://github.com/git-chglog/git-chglog/compare/0.9.1...v0.10.0
[0.9.1]: https://github.com/git-chglog/git-chglog/compare/0.9.0...0.9.1
[0.9.0]: https://github.com/git-chglog/git-chglog/compare/0.8.0...0.9.0
[0.8.0]: https://github.com/git-chglog/git-chglog/compare/0.7.1...0.8.0
[0.7.1]: https://github.com/git-chglog/git-chglog/compare/0.7.0...0.7.1
[0.7.0]: https://github.com/git-chglog/git-chglog/compare/0.6.0...0.7.0
[0.6.0]: https://github.com/git-chglog/git-chglog/compare/0.5.0...0.6.0
[0.5.0]: https://github.com/git-chglog/git-chglog/compare/0.4.0...0.5.0
[0.4.0]: https://github.com/git-chglog/git-chglog/compare/0.3.3...0.4.0
[0.3.3]: https://github.com/git-chglog/git-chglog/compare/0.3.2...0.3.3
[0.3.2]: https://github.com/git-chglog/git-chglog/compare/0.3.1...0.3.2
[0.3.1]: https://github.com/git-chglog/git-chglog/compare/0.3.0...0.3.1
[0.3.0]: https://github.com/git-chglog/git-chglog/compare/0.2.0...0.3.0
[0.2.0]: https://github.com/git-chglog/git-chglog/compare/0.1.0...0.2.0
[0.1.0]: https://github.com/git-chglog/git-chglog/compare/0.0.2...0.1.0
[0.0.2]: https://github.com/git-chglog/git-chglog/compare/0.0.1...0.0.2

@evanchaoli evanchaoli requested a review from clok March 8, 2021 05:56
@clok
Copy link
Collaborator

clok commented Mar 8, 2021

ERROR "(): -- feat(core): Add new feature" is an invalid commit message format

I believe the error is a regression that is caused by #108 because change to survye.v2. I ran into same error with the master branch. Anyway I helped fix the error.

image

This is on me. My initial testing did not produce this, but we did get a report from another user #111

Copy link
Collaborator

@clok clok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evanchaoli Thank you for following up on the feedback and to pointing out (and fixing) the bug that is on master. Very much appreciated.

The primary reason for the change request is for the modifications to the projects .chglog/config.yml.

This feature is close and I really appreciate the work you are putting in! 💯

cmd/git-chglog/questioner.go Outdated Show resolved Hide resolved
.chglog/config.yml Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@clok clok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳 @evanchaoli thank you for listening to the feedback and following up with the changes. Nice work! 🥳

@evanchaoli
Copy link
Contributor Author

@clok As you have approved, are you going to merge this PR?

@clok
Copy link
Collaborator

clok commented Mar 11, 2021

@clok As you have approved, are you going to merge this PR?

I'm seeing a check that hasn't passed correctly, but I'm wondering if it is a legacy check that is no longer valid. I am not sure though. @mavogel can you take a look?

@mavogel mavogel self-requested a review March 11, 2021 07:38
Copy link
Member

@mavogel mavogel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll overrule the legacy check and merge :)

@mavogel mavogel merged commit a1c84d7 into git-chglog:master Mar 11, 2021
@mavogel mavogel linked an issue Mar 12, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for linking to JIRA issues
7 participants