Skip to content

Commit ca39c57

Browse files
committedJun 17, 2020
419: /issue add should allow project names in lower case
Reviewed-by: ehelin
1 parent 1f6b323 commit ca39c57

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed
 

‎bots/pr/src/main/java/org/openjdk/skara/bots/pr/IssueCommand.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private List<Issue> parseIssueList(String allowedPrefix, String issueList) throw
8282
.collect(Collectors.toList());
8383
}
8484
for (var issue : ret) {
85-
if (issue.project().isPresent() && !issue.project().get().equals(allowedPrefix)) {
85+
if (issue.project().isPresent() && !issue.project().get().equalsIgnoreCase(allowedPrefix)) {
8686
throw new InvalidIssue(issue.id(), "This PR can only solve issues in the " + allowedPrefix + " project");
8787
}
8888
}

‎bots/pr/src/test/java/org/openjdk/skara/bots/pr/IssueTests.java

+67
Original file line numberDiff line numberDiff line change
@@ -382,4 +382,71 @@ void issueInBody(TestInfo testInfo) throws IOException {
382382
assertTrue(pr.body().contains("## Issues\n"));
383383
}
384384
}
385+
386+
@Test
387+
void projectPrefix(TestInfo testInfo) throws IOException {
388+
try (var credentials = new HostCredentials(testInfo);
389+
var tempFolder = new TemporaryDirectory()) {
390+
var author = credentials.getHostedRepository();
391+
var integrator = credentials.getHostedRepository();
392+
393+
var issueProject = credentials.getIssueProject();
394+
var censusBuilder = credentials.getCensusBuilder()
395+
.addAuthor(author.forge().currentUser().id());
396+
var prBot = PullRequestBot.newBuilder()
397+
.repo(integrator)
398+
.censusRepo(censusBuilder.build())
399+
.issueProject(issueProject)
400+
.build();
401+
402+
// Populate the projects repository
403+
var localRepo = CheckableRepository.init(tempFolder.path(), author.repositoryType());
404+
var masterHash = localRepo.resolve("master").orElseThrow();
405+
assertFalse(CheckableRepository.hasBeenEdited(localRepo));
406+
localRepo.push(masterHash, author.url(), "master", true);
407+
408+
// Create issues
409+
var issue1 = credentials.createIssue(issueProject, "Issue 1");
410+
var issue2 = credentials.createIssue(issueProject, "Issue 2");
411+
412+
// Make a change with a corresponding PR
413+
var editHash = CheckableRepository.appendAndCommit(localRepo);
414+
localRepo.push(editHash, author.url(), "edit", true);
415+
var pr = credentials.createPullRequest(author, "master", "edit", issue1.id() + ": This is a pull request");
416+
TestBotRunner.runPeriodicItems(prBot);
417+
418+
// Add variations of this issue
419+
pr.addComment("/issue add " + issue2.id().toLowerCase());
420+
TestBotRunner.runPeriodicItems(prBot);
421+
422+
// The bot should reply with a success message
423+
assertLastCommentContains(pr,"Adding additional issue to issue list");
424+
425+
pr.addComment("/issue remove " + issue2.id().toLowerCase());
426+
TestBotRunner.runPeriodicItems(prBot);
427+
428+
// The bot should reply with a success message
429+
assertLastCommentContains(pr,"Removing additional issue from issue list");
430+
431+
// Add variations of this issue
432+
pr.addComment("/issue add " + issue2.id().toUpperCase());
433+
TestBotRunner.runPeriodicItems(prBot);
434+
435+
// The bot should reply with a success message
436+
assertLastCommentContains(pr,"Adding additional issue to issue list");
437+
438+
pr.addComment("/issue remove " + issue2.id().toUpperCase());
439+
TestBotRunner.runPeriodicItems(prBot);
440+
441+
// The bot should reply with a success message
442+
assertLastCommentContains(pr,"Removing additional issue from issue list");
443+
444+
// Add variations of this issue
445+
pr.addComment("/issue add " + issue2.id().split("-")[1]);
446+
TestBotRunner.runPeriodicItems(prBot);
447+
448+
// The bot should reply with a success message
449+
assertLastCommentContains(pr,"Adding additional issue to issue list");
450+
}
451+
}
385452
}

1 commit comments

Comments
 (1)

bridgekeeper[bot] commented on Jun 17, 2020

@bridgekeeper[bot]
Please sign in to comment.