Skip to content
Permalink
Browse files
[FIXED JENKINS-15416] Filter out non head changes if we're on head
  • Loading branch information
mc1arke committed Oct 13, 2012
1 parent c5e2441 commit 1f8811272f1b5b6d0b25b7a9768a34dfb0895f75
Showing with 906 additions and 8 deletions.
  1. +4 −0 src/main/java/hudson/scm/CvsLog.java
  2. +20 −8 src/test/java/hudson/scm/CvsChangeLogHelperTest.java
  3. +882 −0 src/test/resources/hudson/scm/cvsRlogOutputHead.txt
@@ -391,6 +391,10 @@ private void saveChange(final CVSChangeLogSet.File file, final CVSChangeLog chan
return;
}

if (branch != null && location instanceof CvsRepositoryLocation.HeadRepositoryLocation) {
return;
}

// Check the branch/tag name matches the retrieved branch name
if (!(location instanceof CvsRepositoryLocation.HeadRepositoryLocation)
&& !location.getLocationName().equals(branch)) {
@@ -6,6 +6,7 @@

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
@@ -55,10 +56,7 @@ public void testMapCvsLog() throws IOException {
}

public void testMapNonFilteredCvsLog() throws IOException, URISyntaxException {
File changeLogFile = new File(CvsChangeLogHelperTest.class.getResource("cvsRlogOutput_ISSUE-13227.txt").toURI());
int len = (int)changeLogFile.length();
InputStream in = new FileInputStream(changeLogFile); byte[] b = new byte[len]; int total = 0; while (total < len) { int result = in.read(b, total, len - total); if (result == -1) { break; } total += result; }
String logContents = new String(b, Charset.forName("UTF-8"));
String logContents = getFileContents("cvsRlogOutput_ISSUE-13227.txt");

CvsModule module = new CvsModule("portalInt", null);
CvsRepositoryItem item = new CvsRepositoryItem(new CvsRepositoryLocation.BranchRepositoryLocation("d-chg00017366_op_brc_prod-op-2012-04-19", false), new CvsModule[]{module});
@@ -68,10 +66,7 @@ public void testMapNonFilteredCvsLog() throws IOException, URISyntaxException {
}

public void testMapNonFilteredCvsLog2() throws IOException, URISyntaxException {
File changeLogFile = new File(CvsChangeLogHelperTest.class.getResource("cvsRlogOutput2.txt").toURI());
int len = (int)changeLogFile.length();
InputStream in = new FileInputStream(changeLogFile); byte[] b = new byte[len]; int total = 0; while (total < len) { int result = in.read(b, total, len - total); if (result == -1) { break; } total += result; }
String logContents = new String(b, Charset.forName("UTF-8"));
String logContents = getFileContents("cvsRlogOutput2.txt");

CvsModule module = new CvsModule("branch2", null);
CvsRepositoryItem item = new CvsRepositoryItem(new CvsRepositoryLocation.BranchRepositoryLocation(/*"d-chg00017366_op_brc_prod-op-2012-04-19"*/ "branch2", false), new CvsModule[]{module});
@@ -80,6 +75,23 @@ public void testMapNonFilteredCvsLog2() throws IOException, URISyntaxException {
assertEquals(3, set.getChanges().size());
}

public void testMapNonFilteredLogHead() throws IOException, URISyntaxException {
String logContents = getFileContents("cvsRlogOutputHead.txt");

CvsModule module = new CvsModule("product", null);
CvsRepositoryItem item = new CvsRepositoryItem(new CvsRepositoryLocation.HeadRepositoryLocation(), new CvsModule[]{module});
CvsRepository repository = new CvsRepository(":pserver:host:/srv/cvs/repositories/iqdoq", false, null, Arrays.asList(new CvsRepositoryItem[]{item}), new ArrayList<ExcludedRegion>(), -1);
assertTrue(new StringCvsLog(logContents).mapCvsLog(repository.getCvsRoot(), item.getLocation()).getChanges().isEmpty());
}


private String getFileContents(String fileName) throws IOException, URISyntaxException {
File changeLogFile = new File(CvsChangeLogHelperTest.class.getResource(fileName).toURI());
int len = (int)changeLogFile.length();
InputStream in = new FileInputStream(changeLogFile); byte[] b = new byte[len]; int total = 0; while (total < len) { int result = in.read(b, total, len - total); if (result == -1) { break; } total += result; }
return new String(b, Charset.forName("UTF-8"));
}

public static class StringCvsLog extends CvsLog {
private final String text;

Loading

0 comments on commit 1f88112

Please sign in to comment.