Skip to content

Commit f59857a

Browse files
committed
Merge branch 'nb82'
2 parents de49bc4 + 6833482 commit f59857a

17 files changed

Lines changed: 180 additions & 61 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This plugin provides support for GitHub Issue Tracker.
44

55
## Requirements
66

7-
- NetBeans 8.1+
7+
- NetBeans 8.2+
88

99
## Features
1010

@@ -71,6 +71,10 @@ You can get a your OAuth token from the following: Settings > Applications > Per
7171
- Input token description
7272
- Click generate token
7373

74+
## GitHub Enterprise
75+
76+
`api.github.com` is used as the default hostname. If you are using GitHub Enterprise, please set your hostname (e.g. github.example.com).
77+
7478
## Resources
7579

7680
- [egit-github](https://github.com/eclipse/egit-github)

pom.xml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.junichi11</groupId>
55
<artifactId>netbeans-github-issues</artifactId>
6-
<version>0.3.0</version>
6+
<version>0.3.1</version>
77
<packaging>nbm</packaging>
88
<build>
99
<plugins>
@@ -88,11 +88,6 @@
8888
<artifactId>org-openide-dialogs</artifactId>
8989
<version>${netbeans.api.version}</version>
9090
</dependency>
91-
<dependency>
92-
<groupId>org.pegdown</groupId>
93-
<artifactId>pegdown</artifactId>
94-
<version>1.6.0</version>
95-
</dependency>
9691
<dependency>
9792
<groupId>org.eclipse.mylyn.github</groupId>
9893
<artifactId>org.eclipse.egit.github.core</artifactId>
@@ -175,6 +170,23 @@
175170
<artifactId>org-openide-windows</artifactId>
176171
<version>${netbeans.api.version}</version>
177172
</dependency>
173+
<dependency>
174+
<groupId>com.vladsch.flexmark</groupId>
175+
<artifactId>flexmark</artifactId>
176+
<version>0.26.4</version>
177+
</dependency>
178+
<dependency>
179+
<groupId>com.vladsch.flexmark</groupId>
180+
<artifactId>flexmark-ext-gfm-strikethrough</artifactId>
181+
<version>0.26.4</version>
182+
<type>jar</type>
183+
</dependency>
184+
<dependency>
185+
<groupId>com.vladsch.flexmark</groupId>
186+
<artifactId>flexmark-ext-tables</artifactId>
187+
<version>0.26.4</version>
188+
<type>jar</type>
189+
</dependency>
178190
</dependencies>
179191
<properties>
180192
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

src/main/java/com/junichi11/netbeans/modules/github/issues/GitHubCache.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,17 +359,23 @@ public synchronized List<Repository> getForks(boolean force) {
359359
* Get the user for the OAuth Token.
360360
*
361361
* @param oAuthToken OAuth token
362+
* @param hostname hostname (for GitHub Enterprize)
362363
* @return User if it can be got, otherwise {@code null}
363364
*/
364365
@CheckForNull
365-
public static synchronized User getUser(String oAuthToken) {
366+
public static synchronized User getUser(String oAuthToken, String hostname) {
366367
if (StringUtils.isEmpty(oAuthToken)) {
367368
return null;
368369
}
369370

370371
User user = USERS.get(oAuthToken);
371372
if (user == null) {
372-
GitHubClient client = new GitHubClient().setOAuth2Token(oAuthToken);
373+
GitHubClient client;
374+
if (hostname == null || hostname.isEmpty()) {
375+
client = new GitHubClient().setOAuth2Token(oAuthToken);
376+
} else {
377+
client = new GitHubClient(hostname).setOAuth2Token(oAuthToken);
378+
}
373379
UserService userService = new UserService(client);
374380
try {
375381
user = userService.getUser();

src/main/java/com/junichi11/netbeans/modules/github/issues/GitHubIssues.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@
5252
import com.junichi11.netbeans.modules.github.issues.repository.GitHubRepository;
5353
import com.junichi11.netbeans.modules.github.issues.repository.GitHubRepositoryProvider;
5454
import java.awt.Color;
55+
import org.eclipse.egit.github.core.client.IGitHubConstants;
5556
import org.netbeans.modules.bugtracking.issuetable.IssueNode;
5657
import org.netbeans.modules.bugtracking.spi.BugtrackingSupport;
5758
import org.openide.util.RequestProcessor;
58-
import org.pegdown.Extensions;
59-
import org.pegdown.PegDownProcessor;
6059

6160
/**
6261
*
@@ -74,18 +73,19 @@ public final class GitHubIssues {
7473
private GitHubRepositoryProvider repositoryProvider;
7574
private IssueNode.ChangesProvider<GitHubIssue> changesProvider;
7675
private RequestProcessor rp;
77-
private PegDownProcessor pegDownProcessor;
7876
// colors
7977
public static final Color GREEN_COLOR = Color.decode("#6cc644"); // NOI18N
8078
public static final Color RED_COLOR = Color.decode("#bd2c00"); // NOI18N
8179
public static final Color OPEN_STATE_COLOR = Color.decode("#6cc644"); // NOI18N
8280
public static final Color CLOSED_STATE_COLOR = Color.decode("#bd2c00"); // NOI18N
8381
public static final Color MERGED_STATE_COLOR = Color.decode("#6e5494"); // NOI18N
82+
83+
public static final String DEFAULT_HOSTNAME = IGitHubConstants.HOST_API;
8484
// url formats
8585
/**
86-
* https://github.com/[owner]/[repository]/raw/[sha]/[file name]
86+
* https://[hostname]/[owner]/[repository]/raw/[sha]/[file name]
8787
*/
88-
public static final String RAW_URL_FORMAT = "https://github.com/%s/%s/raw/%s/%s"; // NOI18N
88+
public static final String RAW_URL_FORMAT = "https://%s/%s/%s/raw/%s/%s"; // NOI18N
8989

9090
private static final GitHubIssues INSTANCE = new GitHubIssues();
9191

@@ -171,11 +171,4 @@ public String getRecentChanges(GitHubIssue issue) {
171171
return changesProvider;
172172
}
173173

174-
public PegDownProcessor getPegDownProcessor() {
175-
if (pegDownProcessor == null) {
176-
pegDownProcessor = new PegDownProcessor(Extensions.ALL);
177-
}
178-
return pegDownProcessor;
179-
}
180-
181174
}

src/main/java/com/junichi11/netbeans/modules/github/issues/issue/GitHubIssue.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
package com.junichi11.netbeans.modules.github.issues.issue;
4343

4444
import com.junichi11.netbeans.modules.github.issues.GitHubIssueState;
45-
import com.junichi11.netbeans.modules.github.issues.GitHubIssues;
4645
import com.junichi11.netbeans.modules.github.issues.GitHubIssuesConfig;
4746
import com.junichi11.netbeans.modules.github.issues.repository.GitHubRepository;
4847
import com.junichi11.netbeans.modules.github.issues.utils.DateUtils;
48+
import com.junichi11.netbeans.modules.github.issues.utils.StringUtils;
4949
import com.junichi11.netbeans.modules.github.issues.utils.UiUtils;
5050
import java.beans.PropertyChangeListener;
5151
import java.beans.PropertyChangeSupport;
@@ -75,7 +75,6 @@
7575
import org.netbeans.modules.bugtracking.spi.IssueStatusProvider;
7676
import org.netbeans.modules.bugtracking.spi.IssueStatusProvider.Status;
7777
import org.openide.util.NbBundle;
78-
import org.pegdown.PegDownProcessor;
7978

8079
/**
8180
*
@@ -338,9 +337,8 @@ public Comment editComment(Comment comment, String editedBody) {
338337
comment.setBody(editedBody);
339338
Comment editComment = GitHubIssueSupport.editComment(getRepository(), comment);
340339
if (editComment != null) {
341-
PegDownProcessor processor = GitHubIssues.getInstance().getPegDownProcessor();
342340
String body = editComment.getBody();
343-
String bodyHtml = processor.markdownToHtml(body);
341+
String bodyHtml = StringUtils.markdownToHtml(body);
344342
comment.setBodyHtml(String.format("<html>%s</html>", bodyHtml)); // NOI18N
345343
comment.setBody(body);
346344
comment.setUpdatedAt(editComment.getUpdatedAt());

src/main/java/com/junichi11/netbeans/modules/github/issues/issue/ui/CommentTabbedPanel.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@
4141
*/
4242
package com.junichi11.netbeans.modules.github.issues.issue.ui;
4343

44-
import com.junichi11.netbeans.modules.github.issues.GitHubIssues;
44+
import com.junichi11.netbeans.modules.github.issues.utils.StringUtils;
4545
import java.awt.Component;
4646
import java.awt.Dialog;
4747
import java.awt.Font;
4848
import org.openide.DialogDescriptor;
4949
import org.openide.DialogDisplayer;
50-
import org.pegdown.PegDownProcessor;
5150

5251
/**
5352
*
@@ -184,8 +183,7 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) {
184183
private void commentTabbedPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_commentTabbedPaneStateChanged
185184
Component selectedComponent = commentTabbedPane.getSelectedComponent();
186185
if (selectedComponent == commentPreviewPanel) {
187-
PegDownProcessor processor = GitHubIssues.getInstance().getPegDownProcessor();
188-
String html = processor.markdownToHtml(commentWriteTextArea.getText());
186+
String html = StringUtils.markdownToHtml(commentWriteTextArea.getText());
189187
commentPreviewEditorPane.setText(html);
190188
}
191189
}//GEN-LAST:event_commentTabbedPaneStateChanged

src/main/java/com/junichi11/netbeans/modules/github/issues/issue/ui/CreatePullRequestPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
package com.junichi11.netbeans.modules.github.issues.issue.ui;
4343

4444
import com.junichi11.netbeans.modules.github.issues.GitHubIcons;
45+
import com.junichi11.netbeans.modules.github.issues.utils.StringUtils;
4546
import java.awt.Component;
4647
import java.awt.event.ItemEvent;
4748
import java.awt.event.ItemListener;
@@ -58,7 +59,6 @@
5859
import org.eclipse.egit.github.core.Repository;
5960
import org.eclipse.egit.github.core.RepositoryBranch;
6061
import org.openide.util.ChangeSupport;
61-
import org.parboiled.common.StringUtils;
6262

6363
/**
6464
*

src/main/java/com/junichi11/netbeans/modules/github/issues/issue/ui/FileChangedPanel.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,18 @@ public class FileChangedPanel extends javax.swing.JPanel {
7979
private static final long serialVersionUID = 5842222768556582282L;
8080
private static final Logger LOGGER = Logger.getLogger(FileChangedPanel.class.getName());
8181

82+
private final String hostname;
8283
private final CommitFile file;
8384
private final PullRequestMarker marker;
8485
private Component diffView;
8586

8687
/**
8788
* Creates new form FileChendedPanel
8889
*/
89-
public FileChangedPanel(CommitFile file, PullRequestMarker marker) {
90+
public FileChangedPanel(CommitFile file, PullRequestMarker marker, String hostname) {
9091
this.file = file;
9192
this.marker = marker;
93+
this.hostname = hostname;
9294
initComponents();
9395
String filename = file.getFilename();
9496
fileNameLabel.setText(filename);
@@ -200,7 +202,7 @@ public void run() {
200202
try {
201203
handle.start();
202204
URL pullRequestRawUrl = new URL(rawUrl);
203-
URL baseRawUrl = new URL(String.format(GitHubIssues.RAW_URL_FORMAT, owner.getLogin(), name, baseSha, filename));
205+
URL baseRawUrl = new URL(String.format(GitHubIssues.RAW_URL_FORMAT, hostname, owner.getLogin(), name, baseSha, filename));
204206
InputStream prInputStream;
205207
InputStream baseInputStream;
206208
try {

src/main/java/com/junichi11/netbeans/modules/github/issues/issue/ui/FilesChangedPanel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ public void setDetails(PullRequest pullRequest) {
130130
diffUrl = pullRequest.getDiffUrl();
131131
}
132132

133-
public void addFile(CommitFile file, PullRequestMarker marker) {
133+
public void addFile(CommitFile file, PullRequestMarker marker, String hostname) {
134134
assert EventQueue.isDispatchThread();
135135
if (file == null) {
136136
return;
137137
}
138-
FileChangedPanel fileChangedPanel = new FileChangedPanel(file, marker);
138+
FileChangedPanel fileChangedPanel = new FileChangedPanel(file, marker, hostname);
139139
filesPanel.add(fileChangedPanel);
140140
}
141141

src/main/java/com/junichi11/netbeans/modules/github/issues/issue/ui/GitHubIssuePanel.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import com.junichi11.netbeans.modules.github.issues.repository.GitHubRepository;
6060
import com.junichi11.netbeans.modules.github.issues.ui.AttributesListCellRenderer;
6161
import com.junichi11.netbeans.modules.github.issues.utils.GitHubIssuesUtils;
62+
import com.junichi11.netbeans.modules.github.issues.utils.StringUtils;
6263
import com.junichi11.netbeans.modules.github.issues.utils.UiUtils;
6364
import java.awt.Color;
6465
import java.awt.Dimension;
@@ -99,6 +100,7 @@
99100
import org.eclipse.egit.github.core.PullRequestMarker;
100101
import org.eclipse.egit.github.core.RepositoryCommit;
101102
import org.eclipse.egit.github.core.User;
103+
import org.eclipse.egit.github.core.client.IGitHubConstants;
102104
import org.eclipse.egit.github.core.service.IssueService;
103105
import org.netbeans.api.annotations.common.CheckForNull;
104106
import org.openide.DialogDescriptor;
@@ -107,7 +109,6 @@
107109
import org.openide.util.ChangeSupport;
108110
import org.openide.util.NbBundle;
109111
import org.openide.util.RequestProcessor;
110-
import org.pegdown.PegDownProcessor;
111112

112113
/**
113114
*
@@ -411,10 +412,9 @@ public void update() {
411412
List<Comment> comments = gitHubIssue.getComments();
412413
// set count
413414
commentsCollapsibleSectionPanel.setLabel(Bundle.GitHubIssuePanel_comment_count(comments.size()));
414-
PegDownProcessor processor = GitHubIssues.getInstance().getPegDownProcessor();
415415
for (Comment comment : comments) {
416416
String body = comment.getBody();
417-
String bodyHtml = processor.markdownToHtml(body);
417+
String bodyHtml = StringUtils.markdownToHtml(body);
418418
comment.setBodyHtml(String.format("<html>%s</html>", bodyHtml)); // NOI18N
419419
}
420420
commentsPanel.addComments(comments, repository);
@@ -439,8 +439,12 @@ public void update() {
439439
List<CommitFile> pullRequestsFiles = repository.getPullRequestsFiles(issue.getNumber());
440440
filesChangedPanel.setDisplayName(String.format("[Diff] #%s - %s", id, summary)); // NOI18N
441441
filesChangedPanel.removeAllFiles();
442+
String hostname = repository.getHostname();
442443
for (CommitFile file : pullRequestsFiles) {
443-
filesChangedPanel.addFile(file, base);
444+
if (hostname.equals(GitHubIssues.DEFAULT_HOSTNAME)) {
445+
hostname = IGitHubConstants.HOST_DEFAULT;
446+
}
447+
filesChangedPanel.addFile(file, base, hostname);
444448
}
445449
filesChangedPanel.setDetails(pullRequest);
446450
filesChangedcollapsibleSectionPanel.setLabel(Bundle.GitHubIssuePanel_files_changed_count(pullRequestsFiles.size()));

0 commit comments

Comments
 (0)