Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[github] update package/manifest for private repos #1721

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update to only use API when a token is present
I think I got this right. Still need to write the tests.
CynicalBusiness authored Jul 13, 2018
commit ec201ca3eaae56d610da334b07917f8af667af96
11 changes: 7 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
@@ -3476,17 +3476,18 @@ cache(function(query_data, match, sendBadge, request) {
var repo = match[4];
var branch = match[5] || 'master';
var format = match[6];
var hasTokens = !!githubAuth.getTokenDebugInfo({ sanitize: false }).tokens.length
var apiUrl = githubApiUrl + '/repos/' + user + '/' + repo + '/contents/' + type + '.json?ref=' + branch;
var badgeData = getBadgeData(type, query_data);
githubAuth.request(request, apiUrl, { }, function(err, res, buffer) {
var requestCallback = function(err, res, buffer) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
return;
}
try {
var response_data = JSON.parse(buffer);
var json_data = JSON.parse(Buffer.from(response_data.content, 'base64').toString('utf-8'));
var json_data = JSON.parse(buffer);
if (hasTokens) json_data = JSON.parse(Buffer.from(json_data.content, 'base64'));
switch(info) {
case 'v':
case 'version':
@@ -3509,7 +3510,9 @@ cache(function(query_data, match, sendBadge, request) {
badgeData.text[1] = 'invalid data';
sendBadge(format, badgeData);
}
});
}
if (hasTokens) githubAuth.request(request, apiUrl, { }, requestCallback);
else request(apiUrl, requestCallback);
}));

// GitHub contributors integration.