Skip to content

Commit

Permalink
Update stableBrandNewReminder.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm1957 committed Dec 25, 2023
1 parent 1679b04 commit 0eaaee8
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions lib/stableBrandNewReminder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,23 @@ const {
getLabels,
getAllComments,
getGithub,
deleteLabel,
} = require('./common');

async function doIt() {
let labels = await getLabels('');
labels = labels.forEach( (l)=> {
const result = /^(\d\d)\.(\d\d)\.(\d\d\d\d)$/g.exec(l.name);
if (result) {
let targetTs=new Date(result[3], result[2]-1, result[1], 0, 0, 0).getTime();
const nowTs = new Date().getTime();
if ( nowTs > targetTs + 2* 24*60*60*1000) {
console.log(`Label ${l.name} is outdated and will be removed`);
deleteLabel('', l.name);
}
};
});

const issues = await getGithub(`https://api.github.com/repos/iobroker/ioBroker.repositories/issues`);
for (const issue of issues ) {
if (issue.labels.find(label => label.name === 'STABLE - brand new')) {
Expand All @@ -27,14 +41,14 @@ async function doIt() {
const nowTs = new Date().getTime();
if ( nowTs < targetTs ) {
console.log(` will merged after ${dateStr}`);
const label = `* ${dateStr} *`;
const labels = await getLabels('');
//if ( ! labels.filter( (f) => { console.log( f.name ); return f.name===`${label}`})) {
if ( ! labels.includes(`${label}`)) {
const label = `${dateStr}`;
let labels = await getLabels('');
labels = labels.filter( (f) => { return f.name===`${label}`} );
if (!labels.length) {
console.log(` will create label $label}`);
await createLabel(`${label}`, `remind after ${dateStr}`, `#ffffff`);
await createLabel(`${label}`, `remind after ${dateStr}`, `ffffff`);
}
await addLabel(`${issue.number}`, `${label}`);
await addLabel(issue.number, [`${label}`]);
} else {
console.log(` should be merged now (deadline ${dateStr})`);
await addLabel(issue.number, ['⚠️check']);
Expand All @@ -52,14 +66,14 @@ async function doIt() {
const nowTs = Date.now();
if ( nowTs < targetTs ) {
console.log(` will remind at ${dateStr}`);
const label = `* ${dateStr} *`;
const labels = await getLabels('');
//if ( ! labels.filter( (f) => { console.log( f.name ); return f.name===`${label}`})) {
if ( ! labels.includes(`${label}`)) {
const label = `${dateStr}`;
let labels = await getLabels('');
labels = labels.filter( (f) => { return f.name===`${label}`} );
if (!labels.length) {
console.log(` will create label ${label}`);
await createLabel(`${label}`, `remind after ${dateStr}`, `#ffffff`);
await createLabel(`${label}`, `remind after ${dateStr}`, `ffffff`);
}
await addLabel(`${issue.number}`, `${label}`);
await addLabel(issue.number, [`${label}`]);
} else {
console.log(` should be checked now (deadline ${dateStr})`);
await addLabel(issue.number, ['⚠️check']);
Expand Down

0 comments on commit 0eaaee8

Please sign in to comment.