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

Question: Jira integration, change ordering / identify issue in commit #55

Open
arkadioz opened this issue Dec 18, 2023 · 2 comments
Open

Comments

@arkadioz
Copy link

arkadioz commented Dec 18, 2023

When integrating with Jira I notice that the information is presented ordered by the jira issue name, and inside the issue, the commits that were made, you can notice this behaviour in this example https://github.com/tomasbjerre/git-changelog-lib/blob/master/examples/bitbucket_jira.html (notice that SS-165 has an older commit than SS-167, is there a way to make the SS-167 appear first because it is a newer change/commit?).

Based on the example I mentioned, I did this .md template which is successfully gathering the jira issues and also the commits related to them, also the ordering is like in the example above:


<templateContent>
                <![CDATA[
# Changelog for {{repoName}}
{{#tags}}
{{#ifEquals name "Unreleased"}}

---

## [{{name}}]

{{else}}

---

## [[{{name}}](https://bitbucket.org/{{ownerName}}/{{repoName}}/src/{{name}}/)] - {{tagDate}}

{{/ifEquals}}

{{#issues}} {{#hasIssue}}

## Jira ID: [{{issue}}]({{link}})
## Jira Title: {{title}}
## Commits:
{{#commits}}
### {{messageTitle}}
{{#messageBodyItems}}
* {{.}}
{{/messageBodyItems}}

{{authorName}} - {{commitTime}} - [{{hash}}](https://bitbucket.org/{{ownerName}}/{{repoName}}/commits/{{hash}})
{{/commits}}
{{/hasIssue}}
{{^hasIssue}}
{{#commits}}
## Jira ID: N/A
## Jira Title: N/A
## Commits:
### {{messageTitle}}
{{#messageBodyItems}}
* {{.}}
{{/messageBodyItems}}

{{authorName}} - {{commitTime}} - [{{hash}}](https://bitbucket.org/{{ownerName}}/{{repoName}}/commits/{{hash}})
{{/commits}}
{{/hasIssue}}
{{/issues}}
{{/tags}}

                                ]]>
</templateContent>
       

is it possible to apply the ordering I need to it (newest commits first with the respective jira issues)?

Also I was wondering if maybe changing the order of the context variables would help, putting first the {{#commits}} and then inside it {{#issues}} {{#hasIssue}} to make it prioritize the ordering with the commits, but the problem is that I could not figure out if there is a way to check if the commit has a jira issue, like a context variable like {{hasJiraIssue}}.

I was checking if the commits had an inner attribute that I could use for that https://github.com/tomasbjerre/git-changelog-lib?tab=readme-ov-file#context but cannot really figure out if there is a way, like the only way I see to get the Jira Issue is like in the example I mentioned earlier and in this template I pasted, where you first need to start with opening {{#issues}} {{#hasIssue}} and then inside {{#commits}} and not the other way around.

So that you could order by commits and then just show all the Jira issues related to each commit (this would work for me), please let me know if I could properly explain what I am trying to achieve or if needs more detail, I appreciate any help/guidance

@tomasbjerre
Copy link
Owner

No not possible to change the order. Labeling this as enhancement.

@arkadioz
Copy link
Author

arkadioz commented Dec 19, 2023

Okay thank you @tomasbjerre,

Is it possible to make a function that can recognize if the commit msg contains a Jira issue and if it does return it? I think it might be possible with javascript in the template, for example:

In my case you usually find commit msgs like "ACR-750 more or less short description" or "TLYPY-1123: more or less short description" most times this issue is also present in branch name.

maybe a function like getJiraIssueFromCommit(String commitMsg) that would return the Jira issue (if present), so that you could use that in the template for linking it and use it in the template like so:

Jira ID in commit: [getJiraIssueFromCommit({{messageTitle}})](https://server.atlassian.net/browse/getJiraIssueFromCommit({{messageTitle}}))

Would result in:

Jira ID in commit: [ACR-750](https://server.atlassian.net/browse/ACR-750)

EDIT: This is already done, focus on the enhancement of the ordering 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants