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

Upgrade dependencies and rebuild #38

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ typings/
.nuxt

# rollup.js default build output
dist/
# dist/

Choose a reason for hiding this comment

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

dist is important to be able to update since the action runs dist/index.js


# Uncomment the public line if your project uses Gatsby
# https://nextjs.org/blog/next-9-1#public-directory-support
Expand Down
165 changes: 48 additions & 117 deletions dist/fast_forward_action.js
Original file line number Diff line number Diff line change
@@ -1,126 +1,57 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var FastForwardAction = /** @class */ (function () {
function FastForwardAction(client) {
exports.FastForwardAction = void 0;
class FastForwardAction {
client;
constructor(client) {
this.client = client;
this.client = client;
}
;
FastForwardAction.prototype.async_merge_fast_forward = function (client, set_status) {
return __awaiter(this, void 0, void 0, function () {
var pr_number, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
pr_number = client.get_current_pull_request_number();
if (!set_status) return [3 /*break*/, 2];
return [4 /*yield*/, client.set_pull_request_status(pr_number, "success")];
case 1:
_a.sent();
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 7]);
return [4 /*yield*/, client.fast_forward_target_to_source_async(pr_number)];
case 3:
_a.sent();
return [3 /*break*/, 7];
case 4:
error_1 = _a.sent();
console.log(error_1);
if (!set_status) return [3 /*break*/, 6];
return [4 /*yield*/, client.set_pull_request_status(pr_number, "failure")];
case 5:
_a.sent();
_a.label = 6;
case 6: return [2 /*return*/, false];
case 7: return [2 /*return*/, true];
}
});
});
};
FastForwardAction.prototype.async_comment_on_pr = function (client, comment_message, ff_status, prod_branch, stage_branch) {
return __awaiter(this, void 0, void 0, function () {
var pr_number, source_head, target_base, updated_message, stageEqualsProd, error_2, failure_message, updated_message;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
pr_number = client.get_current_pull_request_number();
return [4 /*yield*/, client.get_pull_request_source_head_async(pr_number)];
case 1:
source_head = _a.sent();
return [4 /*yield*/, client.get_pull_request_target_base_async(pr_number)];
case 2:
target_base = _a.sent();
if (!ff_status) return [3 /*break*/, 4];
updated_message = this.insert_branch_names(comment_message.success_message, source_head, target_base, prod_branch, stage_branch);
return [4 /*yield*/, client.comment_on_pull_request_async(pr_number, updated_message)];
case 3:
_a.sent();
return [2 /*return*/];
case 4:
stageEqualsProd = true;
_a.label = 5;
case 5:
_a.trys.push([5, 7, , 8]);
return [4 /*yield*/, client.compate_branch_head(prod_branch, stage_branch)];
case 6:
stageEqualsProd = _a.sent();
return [3 /*break*/, 8];
case 7:
error_2 = _a.sent();
console.log(error_2);
return [3 /*break*/, 8];
case 8:
failure_message = stageEqualsProd ? comment_message.failure_message_same_stage_and_prod : comment_message.failure_message_diff_stage_and_prod;
updated_message = this.insert_branch_names(failure_message, source_head, target_base, prod_branch, stage_branch);
return [4 /*yield*/, client.comment_on_pull_request_async(pr_number, updated_message)];
case 9:
_a.sent();
return [2 /*return*/];
}
});
});
};
FastForwardAction.prototype.insert_branch_names = function (message, source, target, prod_branch, stage_branch) {
async async_merge_fast_forward(client, set_status) {
const pr_number = client.get_current_pull_request_number();
// temporarily set success, then try to merge using ff-only
if (set_status) {
await client.set_pull_request_status(pr_number, "success");
}
try {
await client.fast_forward_target_to_source_async(pr_number);
}
catch (error) {
console.log(error);
if (set_status) {
await client.set_pull_request_status(pr_number, "failure");
}
return false;
}
return true;
}
async async_comment_on_pr(client, comment_message, ff_status, prod_branch, stage_branch) {
const pr_number = client.get_current_pull_request_number();
const source_head = await client.get_pull_request_source_head_async(pr_number);
const target_base = await client.get_pull_request_target_base_async(pr_number);
if (ff_status) {
const updated_message = this.insert_branch_names(comment_message.success_message, source_head, target_base, prod_branch, stage_branch);
await client.comment_on_pull_request_async(pr_number, updated_message);
return;
}
else {
let stageEqualsProd = true;
try {
stageEqualsProd = await client.compate_branch_head(prod_branch, stage_branch);
}
catch (error) {
console.log(error);
}
const failure_message = stageEqualsProd ? comment_message.failure_message_same_stage_and_prod : comment_message.failure_message_diff_stage_and_prod;
const updated_message = this.insert_branch_names(failure_message, source_head, target_base, prod_branch, stage_branch);
await client.comment_on_pull_request_async(pr_number, updated_message);
return;
}
}
insert_branch_names(message, source, target, prod_branch, stage_branch) {
return message.replace(/source_head/g, source).replace(/target_base/g, target).replace(/prod_branch/g, prod_branch).replace(/stage_branch/g, stage_branch);
};
return FastForwardAction;
}());
}
}
exports.FastForwardAction = FastForwardAction;
;
Loading