tkirill / tc-bisect

Bisect plugin for TeamCity
MIT License
10 stars 0 forks source link

branch history is not respected #5

Open stjohnburn opened 9 years ago

stjohnburn commented 9 years ago

tc-bisect only traverses the build history based on buildId. Adding branch filter would reduce the false positives.

tkirill commented 9 years ago

Hi @stjohnburn!

Could you explain the idea of branch filter please? I really can't understand the concept. Where the filter should be added?

stjohnburn commented 9 years ago

Hi @tkirill We use feature branches within TeamCity, so we want to be able to find at which integration point the build failed and not just the first failure. The first failure could be on a feature branch as it was being developed and before it was completed and integrated to master/trunk/main.

You should filter the list of buildIds before starting the bisect algorithm. Looking at your code I think it is in BisectController.java:getChangsIds I think you need to do something like:

    private List<Long> getChangeIds(SBuild build) {
        List<Long> result = new ArrayList<Long>();
        BranchMatcher branchMatcher = BranchMatcher(build.getBranch());
        for (SVcsModification modification : build.getContainingChanges()) {
            if (branchMatcher.isDefined()) {
                BuildCustomizer buildCustomizer = customizerFactory.createBuildCustomizer(build.getBuildType(), null);
                buildCustomizer.setParameters(build.getBuildType().getParameters());
                buildCustomizer.setChangesUpTo(modification);
                 if (branchMatcher.matchesBranch(buildCustomizer.createPromotion().getBranch()) {
                    result.add(modification.getId());
                }
            } else {
                result.add(modification.getId());
            }
        }

This hasn't been tested and I am sure that there are nicer ways to get the branch from the SvcsModification which don't involve creating a promotion.

stjohnburn commented 9 years ago

sorry, meant to just comment and not close the issue.