Skip to content

Commit

Permalink
[FIXED JENKINS-9309] sloccount trend report only works up to last fai…
Browse files Browse the repository at this point in the history
…led build (3th version)
  • Loading branch information
Karsten Brandt authored and Karsten Brandt committed Jun 7, 2012
1 parent 92f5ca9 commit 2d0f2d6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
35 changes: 18 additions & 17 deletions src/main/java/hudson/plugins/sloccount/SloccountPublisher.java
Expand Up @@ -49,29 +49,30 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene

SloccountResult result;

FilePath workspace = build.getWorkspace();
PrintStream logger = listener.getLogger();
SloccountParser parser = new SloccountParser(this.getRealEncoding(), this.getRealPattern(), logger);
SloccountReport report;
SloccountReport report = new SloccountReport();
SloccountParser parser = new SloccountParser(this.getRealEncoding(), this.getRealPattern(), logger, report);

try{
if(this.canContinue(build.getResult())){
if(this.canContinue(build.getResult())){

try{
FilePath workspace = build.getWorkspace();
report = workspace.act(parser);
}else{
// generate an empty report
// TODO: Replace this empty report with the last valid one?
report = new SloccountReport();

}catch(IOException ioe){
ioe.printStackTrace(logger);
return false;

}catch(InterruptedException ie){
ie.printStackTrace(logger);
return false;
}

}catch(IOException ioe){
ioe.printStackTrace(logger);
return false;

}catch(InterruptedException ie){
ie.printStackTrace(logger);
return false;
}else{

// continue with empty report object
}

result = new SloccountResult(report, build);

SloccountBuildAction buildAction = new SloccountBuildAction(build, result);
Expand Down
Expand Up @@ -21,26 +21,27 @@ public class SloccountParser implements FilePath.FileCallable<SloccountReport> {
private final String encoding;
private final String filePattern;
private transient PrintStream logger = null;
private transient SloccountReport report = null;

public SloccountParser(String encoding, String filePattern, PrintStream logger){
public SloccountParser(String encoding, String filePattern, PrintStream logger, SloccountReport report){
this.report = report;
this.logger = logger;
this.filePattern = filePattern;
this.encoding = encoding;
}


public SloccountReport invoke(java.io.File workspace, VirtualChannel channel) throws IOException {
SloccountReport report = new SloccountReport();

FileFinder finder = new FileFinder(this.filePattern);
String[] found = finder.find(workspace);

for(String fileName : found){
this.parse(workspace, fileName, report);
this.parse(workspace, fileName, this.report);
}

report.simplifyNames();
return report;
this.report.simplifyNames();
return this.report;
}

private void parse(java.io.File workspace, String fileName, SloccountReport report) throws IOException {
Expand Down

0 comments on commit 2d0f2d6

Please sign in to comment.