-
Notifications
You must be signed in to change notification settings - Fork 0
Bi 168 add a way to get to jira tickets from GitHub #8
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
base: master
Are you sure you want to change the base?
Bi 168 add a way to get to jira tickets from GitHub #8
Conversation
LOG.debug("Pull request title " + branch_name + " does not contain any ticket of Cozmo project"); | ||
} | ||
while (cozmo_matcher.find()){ | ||
String coz_id = cozmo_matcher.group().replaceAll("coz", jira_link + "coz-"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is coz-
here? I think it is cozmo-
|
||
Pattern cozmo_pattern = Pattern.compile(cozmo); | ||
Matcher cozmo_matcher = cozmo_pattern.matcher(name); | ||
if (!od_matcher.matches()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a space between )
and {
if (!od_matcher.matches()){ | ||
LOG.debug("Pull request title " + branch_name + " does not contain any ticket of Cozmo project"); | ||
} | ||
while (cozmo_matcher.find()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a space between )
and {
final String vcsBranch = version.getVcsBranch(); | ||
String title = ""; | ||
try { | ||
title = api.getPullRequestTitle(repositoryOwner, repositoryName, vcsBranch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should follow 2 space instead of 4
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
public class GetJiraTickets { | ||
private static final Logger LOG = Logger.getInstance(GetJiraTickets.class.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should follow 2 space instead of 4
|
||
Pattern bi_pattern = Pattern.compile(bi); | ||
Matcher bi_matcher = bi_pattern.matcher(name); | ||
if (!od_matcher.matches()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a space between )
and {
if (!od_matcher.matches()){ | ||
LOG.debug("Pull request title " + branch_name + " does not contain any ticket of BI project"); | ||
} | ||
while (bi_matcher.find()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a space between )
and {
String bi_id = bi_matcher.group().replaceAll("bi", jira_link + "bi-"); | ||
list_jira_link.add(bi_id); | ||
} | ||
if (!(list_jira_link.size()>0)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a space between )
and {
*/ | ||
@Nullable | ||
String getPullRequestTitle(@NotNull String repoOwner, | ||
@NotNull String repoName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please line up the @NotNull vertically so it's easier to read
- Merge master into branch - Pass JIRA_LINK_CONF_NAME system parameter into script. Please add a new system parameter JIRA_LINK_CONF_NAME with value "https://ankiinc.atlassian.net/browse/" if using script GetJiraTickets.java - The script support for all of patterns of ticket id (od 123, od-123, od123) - The script works on the branch name
@lip please help me to review |
|
||
public class GetJiraTickets { | ||
private static final Logger LOG = Logger.getInstance(GetJiraTickets.class.getName()); | ||
private static final String od = "od\\d*"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use upper case for constant
comment.append(ticketLink); | ||
comment.append(")\n"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make this as a function.
while (odMatcher.find()) { | ||
String odId = odMatcher.group().replaceAll("od", jiraLink + "od-"); | ||
listJiraLink.add(odId); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make it as a function, then reuse for cozmo, bi
String biId = biMatcher.group().replaceAll("bi", jiraLink + "bi-"); | ||
listJiraLink.add(biId); | ||
} | ||
if (!(listJiraLink.size()>0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just check size == 0
@NotNull String repoName, | ||
@NotNull String branchName) throws IOException { | ||
final String pullRequestId = getPullRequestId(repoName, branchName); | ||
if (pullRequestId == null) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use if (condition) {
//code
} as standard
|
||
final RepoInfo head = pullRequestInfo.head; | ||
if (head != null) { | ||
return head.ref; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should declare a variable to hold return value, and using return at the end of method only
|
||
public class GetJiraTickets { | ||
private static final Logger LOG = Logger.getInstance(GetJiraTickets.class.getName()); | ||
private static final String od = "od\\d*"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this pattern will match all candidate that contain od, we need a pattern to match od d+ or od-d+
for (int i = 0; i < listTicketLink.size(); i++) { | ||
String ticketLink = listTicketLink.get(i); | ||
String ticketId = ticketLink.substring(ticketLink.lastIndexOf("/") + 1).toUpperCase(); | ||
String commentLine = "[" + ticketId + "](" + ticketLink + ")\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static List<String> getListTicketLink(@NotNull String branchName, | ||
@NotNull String jiraLink) { | ||
|
||
String name = branchName.toLowerCase().replaceAll("[^\\da-z]", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only support patterns : od-123 and od 123, no need to replaceAll here
} | ||
if (listTicketLink.size() == 0) { | ||
LOG.debug("Pull request title " + branchName + " does not contain any ticket id"); | ||
listTicketLink = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We no need to assign listTicketLink to null, we can check by get size of it.
|
||
private StringBuilder getJiraTicketComment(@NotNull List<String> listTicketLink) { | ||
StringBuilder jiraLinksComment = new StringBuilder(); | ||
for (int i = 0; i < listTicketLink.size(); i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using for (String ticketLink : listTicketLink) as our standard
final String jiraLink = getJiraLink(build); | ||
final List<String> listTicketLink = GetJiraTickets.getListTicketLink(refBranch, jiraLink); | ||
if (listTicketLink.size() != 0) { | ||
StringBuilder ticketLinkComment = getJiraTicketComment(listTicketLink); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We just need to you String instead of StringBuilder
No description provided.