Skip to content

Commit

Permalink
fix: make log messages more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
fpicalausa committed May 24, 2022
1 parent c81ed10 commit 8f8aeb6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
22 changes: 12 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31632,19 +31632,16 @@ const core = __importStar(__nccwpck_require__(2186));
const date_fns_1 = __nccwpck_require__(3314);
function processBranch(plan, branch, commitComments, params) {
return __awaiter(this, void 0, void 0, function* () {
console.log("-> branch was last updated by " + branch.username + " on " + branch.date);
if (plan.action === "skip") {
console.log(plan.reason);
return;
}
if (plan.action === "keep stale") {
console.log("Branch was marked stale on " + (0, formatISO_1.default)(plan.lastCommentTime));
console.log("It will be removed on " + (0, formatISO_1.default)(plan.cutoffTime));
return;
}
if (plan.action === "mark stale") {
console.log("Marking branch as stale");
console.log("It will be removed on " + (0, formatISO_1.default)(plan.cutoffTime));
console.log("-> branch will be removed on " + (0, formatISO_1.default)(plan.cutoffTime));
console.log("-> marking branch as stale");
if (params.isDryRun) {
console.log("-> (doing nothing because of dry run flag)");
return;
}
const commentTag = "stale:" + branch.branchName;
Expand All @@ -31654,11 +31651,16 @@ function processBranch(plan, branch, commitComments, params) {
commentBody: commitComments_1.TaggedCommitComments.formatCommentMessage(params.staleCommentMessage, branch, params, params.repo),
});
}
console.log("-> branch was marked stale on " + plan.lastCommentTime);
if (plan.action === "keep stale") {
console.log("-> branch will be removed on " + (0, formatISO_1.default)(plan.cutoffTime));
return;
}
if (plan.action === "remove") {
console.log("-> 🗑️ removing stale branch (stale comment date is " +
(0, formatISO_1.default)(plan.lastCommentTime) +
" and cut-off is " + (0, formatISO_1.default)(plan.cutoffTime) + ')');
console.log("-> branch was slated for deletion on " + plan.cutoffTime);
console.log("-> removing branch");
if (params.isDryRun) {
console.log("-> (doing nothing because of dry run flag)");
return;
}
commitComments.deleteBranch(branch);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "remove-stale-branches",
"private": true,
"version": "1.5.1",
"version": "1.5.2",
"description": "Cleanup stale branches from a repository",
"main": "src/index.ts",
"author": "Francois Picalausa <[email protected]>",
Expand Down
32 changes: 17 additions & 15 deletions src/removeStaleBranches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,23 @@ async function processBranch(
commitComments: TaggedCommitComments,
params: Params
) {
console.log(
"-> branch was last updated by " + branch.username + " on " + branch.date);

if (plan.action === "skip") {
console.log(plan.reason);
return;
}

if (plan.action === "keep stale") {
console.log(
"Branch was marked stale on " + formatISO(plan.lastCommentTime)
);
console.log(
"It will be removed on " + formatISO(plan.cutoffTime)
);
return;
}

if (plan.action === "mark stale") {
console.log("Marking branch as stale");
console.log(
"It will be removed on " + formatISO(plan.cutoffTime)
"-> branch will be removed on " + formatISO(plan.cutoffTime)
);
console.log("-> marking branch as stale");

if (params.isDryRun) {
console.log("-> (doing nothing because of dry run flag)");
return;
}

Expand All @@ -59,14 +54,21 @@ async function processBranch(
});
}

if (plan.action === "remove") {
console.log(
"-> branch was marked stale on " + plan.lastCommentTime);

if (plan.action === "keep stale") {
console.log(
"-> 🗑️ removing stale branch (stale comment date is " +
formatISO(plan.lastCommentTime) +
" and cut-off is " + formatISO(plan.cutoffTime) + ')'
"-> branch will be removed on " + formatISO(plan.cutoffTime)
);
return;
}

if (plan.action === "remove") {
console.log("-> branch was slated for deletion on " + plan.cutoffTime);
console.log("-> removing branch");
if (params.isDryRun) {
console.log("-> (doing nothing because of dry run flag)");
return;
}

Expand Down

0 comments on commit 8f8aeb6

Please sign in to comment.