Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 deletions octorun/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,24 @@ ApiWrapper.prototype.getOrgs = function (callback) {
};

ApiWrapper.prototype.publish = function (name, desc, private, organization, callback) {
var callbackHandler = function (error, result) {
callback(error, (!result) ? null : [result.data.name, result.data.clone_url]);
};

if (organization) {
this.octokit.repos.createForOrg({
org: organization,
name: name,
description: desc,
private: private
}, function (error, result) {
callback(error, (!result) ? null : result.data.clone_url);
});
}, callbackHandler);
}
else {
this.octokit.repos.create({
name: name,
description: desc,
private: private
}, function (error, result) {
callback(error, (!result) ? null : result.data.clone_url);
});
}, callbackHandler);
}
};

Expand Down
8 changes: 0 additions & 8 deletions octorun/src/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ var endOfLine = require('os').EOL;
var config = require("./configuration");
var octokitWrapper = require("./octokit");

var lockedRegex = new RegExp("number of login attempts exceeded", "gi");
var twoFactorRegex = new RegExp("must specify two-factor authentication otp code", "gi");
var badCredentialsRegex = new RegExp("bad credentials", "gi");

var scopes = ["user", "repo", "gist", "write:public_key"];

Expand Down Expand Up @@ -48,12 +46,6 @@ var handleAuthentication = function (username, password, onSuccess, onFailure, t
else if (twoFactorRegex.test(err.message)) {
onSuccess(password, "2fa");
}
else if (lockedRegex.test(err.message)) {
onFailure("locked")
}
else if (badCredentialsRegex.test(err.message)) {
onFailure("badcredentials")
}
else {
onFailure(err)
}
Expand Down
5 changes: 0 additions & 5 deletions octorun/src/bin/app-login.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ var handleAuthentication = function (username, password, twoFactor) {
authentication.handleAuthentication(username, password, function (token, status) {
if (status) {
output.custom(status, token);
process.exit();
}
else {
output.success(token);
process.exit();
}
}, function (error) {
output.error(error);
process.exit();
}, twoFactor);
}

Expand All @@ -41,7 +38,6 @@ if (commander.twoFactor) {
}
catch (error) {
output.error(error);
process.exit();
}
}
else {
Expand Down Expand Up @@ -108,7 +104,6 @@ else {
}
catch (error) {
output.error(error);
process.exit();
}
});
}
Expand Down
5 changes: 1 addition & 4 deletions octorun/src/bin/app-organizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@ try {
apiWrapper.getOrgs(function (error, result) {
if (error) {
output.error(error);
process.exit();
}
else {
results = [];
var results = [];
for (var i = 0; i < result.length; i++) {
results.push(result[i].name);
results.push(result[i].login);
}

output.success(results);
process.exit();
}
});
}
catch (error) {
output.error(error);
process.exit();
}
43 changes: 4 additions & 39 deletions octorun/src/bin/app-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var commander = require("commander");
var package = require('../../package.json')
var ApiWrapper = require('../api')
var endOfLine = require('os').EOL;
var output = require('../output');

commander
.version(package.version)
Expand All @@ -13,11 +14,8 @@ commander

if(!commander.repository)
{
process.stdout.write("repository required");
process.stdout.write(endOfLine);
commander.help();
process.exit(-1);
return;
}

var private = false;
Expand All @@ -31,46 +29,13 @@ try {
apiWrapper.publish(commander.repository, commander.description, private, commander.organization,
function (error, result) {
if (error) {
process.stdout.write("error");
process.stdout.write(endOfLine);

process.stdout.write("");
process.stdout.write(endOfLine);

process.stdout.write("");
process.stdout.write(endOfLine);

if (error) {
process.stdout.write(error.toString());
process.stdout.write(endOfLine);
}

process.exit();
output.error(error);
}
else {
process.stdout.write("success");
process.stdout.write(endOfLine);

process.stdout.write(commander.repository);
process.stdout.write(endOfLine);

process.stdout.write(result);
process.stdout.write(endOfLine);
process.exit();
output.success(result);
}
});
}
catch (error) {
process.stdout.write("error");
process.stdout.write(endOfLine);

process.stdout.write("");
process.stdout.write(endOfLine);

if (error) {
process.stdout.write(error.toString());
process.stdout.write(endOfLine);
}

process.exit();
output.error(error);
}
27 changes: 5 additions & 22 deletions octorun/src/bin/app-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var package = require('../../package.json')
var endOfLine = require('os').EOL;
var fs = require('fs');
var util = require('util');
var output = require('../output');

commander
.version(package.version)
Expand Down Expand Up @@ -50,38 +51,20 @@ if (fileContents && host) {

res.on('data', function (d) {
if (success) {
process.stdout.write("success");
process.stdout.write(endOfLine);
process.stdout.write(d);
process.stdout.write(endOfLine);
output.custom("success", d, true);
}
else {
process.stdout.write("error");
process.stdout.write(endOfLine);

process.stdout.write("");
process.stdout.write(endOfLine);

process.stdout.write(d);
process.stdout.write(endOfLine);
output.custom("error", "", true);
}
});

res.on('end', function (d) {
process.exit(success ? 0 : -1);
process.exit();
});
});

req.on('error', function (error) {
process.stdout.write("Error");
process.stdout.write(endOfLine);

if (error) {
process.stdout.write(error.toString());
process.stdout.write(endOfLine);
}

process.exit(-1);
output.error(error);
});

req.write(fileContents);
Expand Down
21 changes: 15 additions & 6 deletions octorun/src/output.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var endOfLine = require('os').EOL;

var outputResult = function (status, results, errors) {
var outputResult = function (status, results, errors, preventExit) {
process.stdout.write(status);
process.stdout.write(endOfLine);

Expand All @@ -24,8 +24,9 @@ var outputResult = function (status, results, errors) {
process.stdout.write(endOfLine);
}
}

throw "Unsupported result output";
else {
throw "Unsupported result output";
}
}

if (errors) {
Expand All @@ -37,26 +38,34 @@ var outputResult = function (status, results, errors) {
for (var errorIndex = 0; errorIndex < errors.length; errorIndex++) {
var error = errors[errorIndex];
if (typeof error !== 'string') {
throw "Unsupported result output";
throw "Unsupported error output";
}

process.stdout.write(error);
process.stdout.write(endOfLine);
}
}
else if (errors.toString) {
process.stdout.write(errors.toString());
process.stdout.write(endOfLine);
}
else {
process.stdout.write(errors);
process.stdout.write(endOfLine);
}
}

if (!preventExit) {
process.exit();
}
}

var outputSuccess = function (results) {
outputResult("success", results);
}

var outputCustom = function (status, results) {
outputResult(status, results);
var outputCustom = function (status, results, preventExit) {
outputResult(status, results, undefined, preventExit);
}

var outputError = function (errors) {
Expand Down
2 changes: 1 addition & 1 deletion octorun/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b91b7b60
46811135
21 changes: 3 additions & 18 deletions src/GitHub.Api/Application/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,7 @@ private async Task<GitHubRepository> CreateRepositoryInternal(string repositoryN
};
}

if (ret.Output.Any())
{
throw new ApiClientException(string.Join(Environment.NewLine, ret.Output));
}

throw new ApiClientException("Publish failed");
throw new ApiClientException(ret.GetApiErrorMessage() ?? "Publish failed");
}
catch (Exception ex)
{
Expand Down Expand Up @@ -294,12 +289,7 @@ private async Task GetOrganizationInternal(Action<Organization[]> onSuccess, Act
return;
}

if (ret.Output.Any())
{
throw new ApiClientException(string.Join(Environment.NewLine, ret.Output));
}

throw new ApiClientException("Error getting organizations");
throw new ApiClientException(ret.GetApiErrorMessage() ?? "Error getting organizations");
}
catch (Exception ex)
{
Expand Down Expand Up @@ -332,12 +322,7 @@ private async Task<GitHubUser> GetCurrentUserInternal()
};
}

if (ret.Output.Any())
{
throw new ApiClientException(string.Join(Environment.NewLine, ret.Output));
}

throw new ApiClientException("Error validating current user");
throw new ApiClientException(ret.GetApiErrorMessage() ?? "Error validating current user");
}
catch (KeychainEmptyException)
{
Expand Down
2 changes: 1 addition & 1 deletion src/GitHub.Api/Authentication/Keychain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,6 @@ private void UpdateConnections(Connection[] conns)
public Connection[] Connections => connections.Values.ToArray();
public IList<UriString> Hosts => connections.Keys.ToArray();
public bool HasKeys => connections.Any();
public bool NeedsLoad => HasKeys && !string.IsNullOrEmpty(FindOrCreateAdapter(connections.First().Value.Host).Credential.Token);
public bool NeedsLoad => HasKeys && !string.IsNullOrEmpty(FindOrCreateAdapter(connections.First().Value.Host).Credential?.Token);
}
}
17 changes: 1 addition & 16 deletions src/GitHub.Api/Authentication/LoginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,7 @@ private async Task<LoginResultData> TryLogin(
return new LoginResultData(resultCodes, message, host, ret.Output[0]);
}

if (ret.IsBadCredentials)
{
return new LoginResultData(LoginResultCodes.Failed, "Bad credentials.", host, ret.Output[0]);
}

if (ret.IsLocked)
{
return new LoginResultData(LoginResultCodes.LockedOut, "Account locked.", host, ret.Output[0]);
}

if (ret.Output.Any())
{
return new LoginResultData(LoginResultCodes.Failed, "Failed.", host, ret.Output[0]);
}

return new LoginResultData(LoginResultCodes.Failed, "Failed.", host);
return new LoginResultData(LoginResultCodes.Failed, ret.GetApiErrorMessage() ?? "Failed.", host);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/GitHub.Api/Installer/OctorunInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class OctorunInstallDetails
public const string DefaultZipMd5Url = "https://ghfvs-installer.github.com/unity/octorun/octorun.zip.md5";
public const string DefaultZipUrl = "https://ghfvs-installer.github.com/unity/octorun/octorun.zip";

public const string PackageVersion = "b91b7b60";
public const string PackageVersion = "46811135";
private const string PackageName = "octorun";
private const string zipFile = "octorun.zip";

Expand Down
4 changes: 2 additions & 2 deletions src/GitHub.Api/Resources/octorun.zip
Git LFS file not shown
2 changes: 1 addition & 1 deletion src/GitHub.Api/Resources/octorun.zip.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7cdaa49008b8c996343e07670100bce2
070a4561bf70031ad54ca5884f97f546
Loading