Skip to content

Commit

Permalink
add tscan
Browse files Browse the repository at this point in the history
  • Loading branch information
kgyrtkirk committed Feb 19, 2020
1 parent 64d6d75 commit 677d132
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/main/java/hu/rxd/toolbox/TicketUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -14,17 +17,21 @@
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevObject;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.revwalk.filter.RevFilter;
import org.eclipse.jgit.treewalk.AbstractTreeIterator;
import org.eclipse.jgit.treewalk.CanonicalTreeParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Joiner;

import hu.rxd.toolbox.jira.HiveTicket;
import hu.rxd.toolbox.jira.ToolboxSettings;
import hu.rxd.toolbox.qtest.diff.CachedURL;
import net.rcarz.jiraclient.Attachment;
import net.rcarz.jiraclient.Comment;

public class TicketUtils {
static Logger LOG = LoggerFactory.getLogger(TicketUtils.class);
Expand Down Expand Up @@ -138,4 +145,57 @@ private static String extractJiraKey(String currentBranch) {
return key;
}

static class TxProcessor {

private int nofromat;
private List<String> patterns = new ArrayList<>();

public void process(String line) {
if (line.equals("{noformat}")) {
nofromat++;
return;
}
if (nofromat == 1) {
processTestLine(line);
}

}

private void processTestLine(String line) {
String parts[] = line.split(" ");
String test = parts[0];
System.out.println(test);
//String testM = test.replaceAll("\\.([^\\.]+)$", "#$1");

String[] p2 = test.split("\\.");
System.out.println(p2.length);

String testM = p2[p2.length - 2] + "#" + p2[p2.length - 1];
patterns.add(testM);
}

}

public static List<String> getFailed(HiveTicket hiveTicket) {
HiveTicket t = hiveTicket;
Comment c = t.getLastQAComment();

String[] lines = c.getBody().split("\n");
TxProcessor txp = new TxProcessor();
for (String string : lines) {
txp.process(string);
}

return txp.patterns;
//
// // TestEntries res2 = res.filterFailed().limit(600);
// // System.out.println(res2);
// // String pat = res2.getSimpleMavenTestPattern();
// // System.out.println("pat len:" + pat.length());
// // try (PrintStream ps = new PrintStream(args[1])) {
// // ps.println(pat);
// // }

}

}
27 changes: 27 additions & 0 deletions src/main/java/hu/rxd/toolbox/Toolbox.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import hu.rxd.toolbox.qtest.QTDiffRunner;
import hu.rxd.toolbox.qtest.diff.CachedURL;
import net.rcarz.jiraclient.Attachment;
import net.rcarz.jiraclient.Comment;

public class Toolbox {

Expand Down Expand Up @@ -94,7 +95,33 @@ public static void main(String[] args) throws FileNotFoundException, Exception {
}
return;
}
// if (args[0].equals(""))
if (args[0].startsWith("ticketScan")) {
List<String> failedPats = TicketUtils.getFailed(new HiveTicket(args[2]));

try (PrintStream ps = new PrintStream(args[1])) {
String s = Joiner.on(",").join(failedPats);
ps.println(s);
}

// String ticket = args[2];
// HiveTicket
// .getMatchingTickets("assignee = kgyrtkirk and ")
// HiveTicket t = new HiveTicket(ticket);
// Comment c = t.getLastQAComment();
// System.out.println(c);
// String[] lines = c.getBody().split("\n");
//
// // TestEntries res2 = res.filterFailed().limit(600);
// // System.out.println(res2);
// // String pat = res2.getSimpleMavenTestPattern();
// // System.out.println("pat len:" + pat.length());
// // try (PrintStream ps = new PrintStream(args[1])) {
// // ps.println(pat);
// // }
return;
}
//
if (args[0].equals("applicator")) {
Applicator applicator = new Applicator(new HiveTicket(args[1]));

Expand Down

0 comments on commit 677d132

Please sign in to comment.