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.
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.
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.
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.
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.
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.
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.
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.
need a space between ) and {
| * @throws IOException | ||
| */ | ||
| @Nullable | ||
| String getPullRequestTitle(@NotNull String repoOwner, |
There was a problem hiding this comment.
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.
We should use upper case for constant
| comment.append(ticketLink); | ||
| comment.append(")\n"); | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
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.
just check size == 0
| public String findPullRequestLabel(@NotNull String repoOwner, | ||
| @NotNull String repoName, | ||
| @NotNull String branchName) throws IOException { | ||
| final String pullRequestId = getPullRequestId(repoName, branchName); |
There was a problem hiding this comment.
use if (condition) {
//code
} as standard
| final PullRequestInfo pullRequestInfo = processResponse(get, PullRequestInfo.class); | ||
|
|
||
| final RepoInfo head = pullRequestInfo.head; | ||
| if (head != null) { |
There was a problem hiding this comment.
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.
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"; |
| 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.
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.
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.
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.
We just need to you String instead of StringBuilder
No description provided.