Skip to content

Commit 360f3f8

Browse files
authored
Merge pull request #9111 from mbien/git-codeberg-hyperlinks
Update DefaultGitHyperlinkProvider to support codeberg projects.
2 parents daa1f43 + cc2b681 commit 360f3f8

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

ide/git/src/org/netbeans/modules/git/ui/history/DefaultGitHyperlinkProvider.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,27 @@ private static void openIssue(Path repo, String id) {
107107
if (origin != null) {
108108
for (String str : origin.getUris()) {
109109
GitURI uri = new GitURI(str);
110-
String path = uri.getPath().substring(0, uri.getPath().length() - 4); // remove .git postfix
111-
if (!path.startsWith("/")) {
112-
path = "/" + path;
113-
}
114-
String page = null;
115-
if (uri.getHost().equals("github.com")) {
116-
page = "/pull/" + id; // url works for issues too
117-
} else if (uri.getHost().contains("gitlab")) {
118-
page = "/-/issues/" + id; // does gitlab auto link merge_requests ?
110+
String host = uri.getHost();
111+
if (host == null) {
112+
continue;
119113
}
114+
String page = switch (host) {
115+
case "github.com" -> "/pull/" + id; // for issues and PRs
116+
case "codeberg.org" -> "/pulls/" + id; // for issues and PRs
117+
default -> {
118+
if (host.contains("gitlab")) {
119+
yield "/-/issues/" + id; // does gitlab auto link merge_requests ?
120+
} else {
121+
yield null;
122+
}
123+
}
124+
};
120125
if (page != null) {
121-
URI link = URI.create("https://" + uri.getHost() + path + page);
126+
String path = uri.getPath().substring(0, uri.getPath().length() - 4); // remove .git postfix
127+
if (!path.startsWith("/")) {
128+
path = "/" + path;
129+
}
130+
URI link = URI.create("https://" + host + path + page);
122131
Desktop.getDesktop().browse(link);
123132
return;
124133
}

0 commit comments

Comments
 (0)