Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import hudson.util.ListBoxModel;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
Expand Down Expand Up @@ -1574,15 +1576,21 @@ public List<Action> retrieveActions(
// trusted source
listener.getLogger().printf("Looking up details of %s...%n", getRepoOwner());
List<Action> result = new ArrayList<>();
String apiUri = Util.fixEmptyAndTrim(getApiUri());
StandardCredentials credentials =
Connector.lookupScanCredentials((Item) owner, getApiUri(), credentialsId);
GitHub hub = Connector.connect(getApiUri(), credentials);
Connector.lookupScanCredentials((Item) owner, apiUri, credentialsId);
GitHub hub = Connector.connect(apiUri, credentials);
boolean privateMode = apiUri == null ? false : determinePrivateMode(apiUri);
Comment thread
Vlatombe marked this conversation as resolved.
Outdated
try {
Connector.configureLocalRateLimitChecker(listener, hub);
GHUser u = hub.getUser(getRepoOwner());
String objectUrl = u.getHtmlUrl() == null ? null : u.getHtmlUrl().toExternalForm();
result.add(new ObjectMetadataAction(Util.fixEmpty(u.getName()), null, objectUrl));
result.add(new GitHubOrgMetadataAction(u));
if (privateMode) {
result.add(new GitHubOrgMetadataAction((String) null));
} else {
result.add(new GitHubOrgMetadataAction(u));
}
result.add(new GitHubLink("icon-github-logo", u.getHtmlUrl()));
if (objectUrl == null) {
listener.getLogger().println("Organization URL: unspecified");
Expand All @@ -1600,6 +1608,22 @@ public List<Action> retrieveActions(
}
}

private static boolean determinePrivateMode(String apiUri) {
if (apiURL == null || apiURL.equals(GitHubServerConfig.GITHUB_URL)) {
Comment thread
jtnord marked this conversation as resolved.
Outdated
return false;
}
try {
GitHub.connectToEnterpriseAnonymously(apiUri).checkApiUrlValidity();
} catch (MalformedURLException e) {
return true; // URL is bogus so there is never going to be an avatar - or anything else come to think of it
} catch (IOException e) {
if (e.getMessage().contains("private mode enabled")) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

return true;
}
}
return false;
}

/** {@inheritDoc} */
@Override
public void afterSave(@NonNull SCMNavigatorOwner owner) {
Expand Down