Skip to content
Browse files
934: Bots incorrectly assigned "build" label despite no obvious match…
…ing rule

Reviewed-by: erikj
  • Loading branch information
rwestberg committed Apr 15, 2021
1 parent e3b75ff commit 132acee4bac602881c45041e2800efc7fd7056bf
Showing 2 changed files with 57 additions and 2 deletions.
@@ -123,6 +123,57 @@ void match(TestInfo testInfo) throws IOException {

void copy(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo);
var tempFolder = new TemporaryDirectory()) {
var author = credentials.getHostedRepository();
var reviewer = credentials.getHostedRepository();

var labelConfiguration = LabelConfigurationJson.builder()
.addMatchers("test1", List.of(Pattern.compile("a.txt")))
.addMatchers("test2", List.of(Pattern.compile("b.txt")))
var censusBuilder = credentials.getCensusBuilder()
var labelBot = PullRequestBot.newBuilder()

// Populate the projects repository
var localRepoFolder = tempFolder.path();
var localRepo = CheckableRepository.init(localRepoFolder, author.repositoryType());
var masterHash = localRepo.resolve("master").orElseThrow();
localRepo.push(masterHash, author.url(), "master", true);

// Add an unrelated file to master
var fileB = localRepoFolder.resolve("b.txt");
Files.writeString(fileB, "Hello");
var hashB = localRepo.commit("test1", "test", "test@test");
localRepo.push(hashB, author.url(), "master");

// Make a change with a corresponding PR
var editHash = CheckableRepository.appendAndCommit(localRepo);
localRepo.push(editHash, author.url(), "edit", true);

var fileA = localRepoFolder.resolve("a.txt");
Files.writeString(fileA, "Hello");
var hashA = localRepo.commit("test1", "test", "test@test");
localRepo.push(hashA, author.url(), "edit");

var pr = credentials.createPullRequest(author, "master", "edit", "This is a pull request");

// Check the status - there should now be a test1 label
assertEquals(Set.of("rfr", "test1"), new HashSet<>(pr.labelNames()));

void initialLabelCommand(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo);
@@ -186,8 +186,12 @@ public static Set<Path> changedFiles(PullRequest pr, Repository localRepo) throw
var ret = new HashSet<Path>();
var changes = localRepo.diff(baseHash(pr, localRepo), pr.headHash());
for (var patch : changes.patches()) {;
if (patch.status().isDeleted() || patch.status().isRenamed()) {
if (!patch.status().isDeleted()) {;
return ret;

1 comment on commit 132acee

Copy link

@openjdk-notifier openjdk-notifier bot commented on 132acee Apr 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.