Permalink
1 comment
on commit
sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add census support for the issue notifier
Reviewed-by: erikj
- Loading branch information
Showing
with
312 additions
and 129 deletions.
- +9 −6 bots/notify/src/main/java/org/openjdk/skara/bots/notify/PullRequestListener.java
- +21 −20 bots/notify/src/main/java/org/openjdk/skara/bots/notify/PullRequestWorkItem.java
- +5 −4 bots/notify/src/main/java/org/openjdk/skara/bots/notify/RepositoryListener.java
- +13 −12 bots/notify/src/main/java/org/openjdk/skara/bots/notify/RepositoryWorkItem.java
- +7 −1 bots/notify/src/main/java/org/openjdk/skara/bots/notify/comment/CommitCommentNotifier.java
- +84 −0 bots/notify/src/main/java/org/openjdk/skara/bots/notify/issue/CensusInstance.java
- +34 −14 bots/notify/src/main/java/org/openjdk/skara/bots/notify/issue/IssueNotifier.java
- +21 −1 bots/notify/src/main/java/org/openjdk/skara/bots/notify/issue/IssueNotifierBuilder.java
- +8 −0 bots/notify/src/main/java/org/openjdk/skara/bots/notify/issue/IssueNotifierFactory.java
- +2 −2 bots/notify/src/main/java/org/openjdk/skara/bots/notify/json/JsonNotifier.java
- +6 −5 bots/notify/src/main/java/org/openjdk/skara/bots/notify/mailinglist/MailingListNotifier.java
- +8 −3 bots/notify/src/main/java/org/openjdk/skara/bots/notify/prbranch/PullRequestBranchNotifier.java
- +3 −2 bots/notify/src/main/java/org/openjdk/skara/bots/notify/slack/SlackNotifier.java
- +8 −8 bots/notify/src/test/java/org/openjdk/skara/bots/notify/UpdaterTests.java
- +83 −6 bots/notify/src/test/java/org/openjdk/skara/bots/notify/issue/IssueNotifierTests.java
- +0 −2 issuetracker/src/main/java/org/openjdk/skara/issuetracker/IssueProject.java
- +0 −28 issuetracker/src/main/java/org/openjdk/skara/issuetracker/jira/JiraProject.java
- +0 −9 test/src/main/java/org/openjdk/skara/test/TestHost.java
- +0 −6 test/src/main/java/org/openjdk/skara/test/TestIssueProject.java
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
package org.openjdk.skara.bots.notify.issue; | ||
|
||
import org.openjdk.skara.census.*; | ||
import org.openjdk.skara.forge.HostedRepository; | ||
import org.openjdk.skara.vcs.Repository; | ||
|
||
import java.io.*; | ||
import java.net.URLEncoder; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Path; | ||
import java.util.Optional; | ||
|
||
class CensusInstance { | ||
private final Namespace namespace; | ||
|
||
private CensusInstance(Namespace namespace) { | ||
this.namespace = namespace; | ||
} | ||
|
||
private static Repository initialize(HostedRepository repo, String ref, Path folder) { | ||
try { | ||
return Repository.materialize(folder, repo.url(), "+" + ref + ":" + "issue_census_" + repo.name()); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Failed to retrieve census to " + folder, e); | ||
} | ||
} | ||
|
||
private static Namespace namespace(Census census, String hostNamespace) { | ||
var namespace = census.namespace(hostNamespace); | ||
if (namespace == null) { | ||
throw new RuntimeException("Namespace not found in census: " + hostNamespace); | ||
} | ||
|
||
return namespace; | ||
} | ||
|
||
static CensusInstance create(HostedRepository censusRepo, String censusRef, Path folder, String namespace) { | ||
var repoName = censusRepo.url().getHost() + "/" + censusRepo.name(); | ||
var repoFolder = folder.resolve(URLEncoder.encode(repoName, StandardCharsets.UTF_8)); | ||
try { | ||
var localRepo = Repository.get(repoFolder) | ||
.or(() -> Optional.of(initialize(censusRepo, censusRef, repoFolder))) | ||
.orElseThrow(); | ||
var hash = localRepo.fetch(censusRepo.url(), censusRef, false); | ||
localRepo.checkout(hash, true); | ||
} catch (IOException e) { | ||
initialize(censusRepo, censusRef, repoFolder); | ||
} | ||
|
||
try { | ||
var census = Census.parse(repoFolder); | ||
var ns = namespace(census, namespace); | ||
return new CensusInstance(ns); | ||
} catch (IOException e) { | ||
throw new UncheckedIOException("Cannot parse census at " + repoFolder, e); | ||
} | ||
} | ||
|
||
Namespace namespace() { | ||
return namespace; | ||
} | ||
} |
Oops, something went wrong.
b8f1016
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review